Skip to content

Commit

Permalink
Lucene 9.10 upgrade (#626)
Browse files Browse the repository at this point in the history
* Bump lucene version to 9.10

* Compute numHitsToCollect before creating Collector
  • Loading branch information
sarthakn7 authored Mar 6, 2024
1 parent 353f6bc commit 1c534fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _artifactId = 'server'
//This is for https://github.com/gradle/gradle/issues/11308
System.setProperty("org.gradle.internal.publish.checksums.insecure", "True")

def luceneVersion = '9.9.0'
def luceneVersion = '9.10.0'
project.ext.slf4jVersion = '2.0.0-alpha1'
project.ext.grpcVersion = '1.46.0'
project.ext.lz4Version = '1.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ private static DocCollector buildDocCollector(CollectorCreatorContext collectorC
.collect(Collectors.toList());

DocCollector docCollector;
if (searchRequest.getQuery().hasCompletionQuery()) {
int numHitsToCollect = DocCollector.computeNumHitsToCollect(searchRequest);
// If we don't need hits, just count recalled docs
if (numHitsToCollect == 0) {
docCollector = new HitCountCollector(collectorCreatorContext, additionalCollectors);
} else if (searchRequest.getQuery().hasCompletionQuery()) {
docCollector = new MyTopSuggestDocsCollector(collectorCreatorContext, additionalCollectors);
} else if (searchRequest.getQuerySort().getFields().getSortedFieldsList().isEmpty()) {
if (hasLargeNumHits(searchRequest)) {
Expand All @@ -398,10 +402,6 @@ private static DocCollector buildDocCollector(CollectorCreatorContext collectorC
} else {
docCollector = new SortFieldCollector(collectorCreatorContext, additionalCollectors);
}
// If we don't need hits, just count recalled docs
if (docCollector.getNumHitsToCollect() == 0) {
docCollector = new HitCountCollector(collectorCreatorContext, additionalCollectors);
}
return docCollector;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public DocCollector(
this.indexState = context.getIndexState();
this.additionalCollectors = additionalCollectors;

numHitsToCollect = computeNumHitsToCollect(request);
}

public static int computeNumHitsToCollect(SearchRequest request) {
// determine how many hits to collect based on request, facets and rescore window
int collectHits = request.getTopHits();
for (Facet facet : request.getFacetsList()) {
Expand All @@ -77,7 +81,7 @@ public DocCollector(
collectHits = windowSize;
}
}
numHitsToCollect = collectHits;
return collectHits;
}

/**
Expand Down

0 comments on commit 1c534fe

Please sign in to comment.