Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't count hits via the collector if the hit count can be computed from index stats. #33701

Merged
merged 2 commits into from
Sep 14, 2018

Conversation

jpountz
Copy link
Contributor

@jpountz jpountz commented Sep 14, 2018

This is something that we were already doing when sorting by field, which is
now also done when sorting by score. As-is this change will speed up top-k
term queries. This could work for match_all queries as well when we
implement the setMinCompetitiveScore API on their Scorer.

…rom index stats.

This is something that we were already doing when sorting by field, which is
now also done when sorting by score. As-is this change will speed up top-k
`term` queries. This could work for `match_all` queries as well when we
implement the `setMinCompetitiveScore` API on their Scorer.
@jpountz jpountz added >enhancement :Search/Search Search-related issues that do not fall into other categories labels Sep 14, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@jpountz jpountz requested a review from jimczi September 14, 2018 07:40
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment regarding bwc issue with top docs serialization. LGTM otherwise.

topDocsSupplier = new CachedSupplier<>(topDocsCollector::topDocs);
if (hitCount == -1) {
assert trackTotalHits == false;
totalHitsSupplier = () -> new TotalHits(topDocsSupplier.get().scoreDocs.length,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's return new TotalHits(0, TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO) for now ? It is translated to -1 by the coordinating node anyway since track_total_hits is false in this case. We also need to handle bwc for mixed search with 6x node. Currently we have an exception if the hit count is greater than 0 and not an exact count so I suspect that this change could break some bwc tests randomly. We can revise this when we add the support for track_total_hits as a number ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will do.

@jpountz jpountz added the v7.0.0 label Sep 14, 2018
@jpountz jpountz merged commit 4f68104 into elastic:master Sep 14, 2018
@jpountz
Copy link
Contributor Author

jpountz commented Sep 14, 2018

Thanks @jimczi

@jpountz jpountz deleted the enhancement/no_hit_count_if_shortcut branch September 14, 2018 12:59
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Sep 14, 2018
* master: (24 commits)
  Only notify ready global checkpoint listeners (elastic#33690)
  Don't count hits via the collector if the hit count can be computed from index stats. (elastic#33701)
  Expose retries for CCR fetch failures (elastic#33694)
  Test fix - Graph vertices could appear in different orders based on map insertion sequence (elastic#33709)
  Structured audit logging (elastic#31931)
  Core: Add DateFormatter interface for java time parsing (elastic#33467)
  [CCR] Check whether the rejected execution exception has the shutdown flag set (elastic#33703)
  Mute ClusterDisruptionIT#testSendingShardFailure
  Revert "Mute FullClusterRestartSettingsUpgradeIT"
  Adjust BWC version on settings upgrade test (elastic#33650)
  [ML] Allow overrides for some file structure detection decisions (elastic#33630)
  Adapt skip version for doc_values format deprecation
  [TEST] wait for no initializing shards
  [Docs] Minor fix in `has_child` javadoc comment (elastic#33674)
  Mute FullClusterRestartSettingsUpgradeIT
  [Kerberos] Add realm name & UPN to user metadata (elastic#33338)
  [TESTS] Disable specific locales for RestrictedTrustManagerTest (elastic#33299)
  SQL: Return functions in JDBC driver metadata (elastic#33672)
  SCRIPTING: Move terms_set Context to its Own Class (elastic#33602)
  AwaitsFix testRestoreMinmal
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants