File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
server/src/main/java/org/elasticsearch/search/vectors Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ public Query rewrite(IndexSearcher indexSearcher) throws IOException {
120120 // we need to ensure we are getting at least 2*k results to ensure we cover overspill duplicates
121121 // TODO move the logic for automatically adjusting percentages to the query, so we can only pass
122122 // 2k to the collector.
123- KnnCollectorManager knnCollectorManager = getKnnCollectorManager (Math .max ( Math . round (2f * k ), numCands ), indexSearcher );
123+ KnnCollectorManager knnCollectorManager = getKnnCollectorManager (Math .round (2f * k ), indexSearcher );
124124 TaskExecutor taskExecutor = indexSearcher .getTaskExecutor ();
125125 List <LeafReaderContext > leafReaderContexts = reader .leaves ();
126126
@@ -136,7 +136,9 @@ public Query rewrite(IndexSearcher indexSearcher) throws IOException {
136136 final float visitRatio ;
137137 if (providedVisitRatio == 0.0f ) {
138138 // dynamically set the percentage
139- float expected = (float ) Math .round (Math .log10 (totalVectors ) * Math .log10 (totalVectors ) * (numCands ));
139+ float expected = (float ) Math .round (
140+ Math .log10 (totalVectors ) * Math .log10 (totalVectors ) * (Math .min (10_000 , Math .max (numCands , 5 * k )))
141+ );
140142 visitRatio = expected / totalVectors ;
141143 } else {
142144 visitRatio = providedVisitRatio ;
You can’t perform that action at this time.
0 commit comments