@@ -229,20 +229,18 @@ public final void search(String field, float[] target, KnnCollector knnCollector
229229 }
230230
231231 FieldEntry entry = fields .get (fieldInfo .number );
232- long maxVectorVisited ;
233232 if (visitRatio == DYNAMIC_VISIT_RATIO ) {
234233 // empirically based, and a good dynamic to get decent recall while scaling a la "efSearch"
235234 // scaling by the number of vectors vs. the nearest neighbors requested
236235 // not perfect, but a comparative heuristic.
237236 // TODO: we might want to consider the density of the centroids as experiments shows that for fewer vectors per centroid,
238237 // the least vectors we need to score to get a good recall.
239- maxVectorVisited = Math .round (1.75f * Math .log10 (knnCollector . k ()) * Math .log10 (knnCollector . k () ) * (knnCollector .k ()));
238+ float estimated = Math .round (Math .log10 (numVectors ) * Math .log10 (numVectors ) * (knnCollector .k ()));
240239 // clip so we visit at least one vector
241- maxVectorVisited = Math .max (maxVectorVisited , 1L );
242- } else {
243- // we account for soar vectors here. We can potentially visit a vector twice so we multiply by 2 here.
244- maxVectorVisited = (long ) (2.0 * visitRatio * numVectors );
240+ visitRatio = estimated / numVectors ;
245241 }
242+ // we account for soar vectors here. We can potentially visit a vector twice so we multiply by 2 here.
243+ long maxVectorVisited = (long ) (2.0 * visitRatio * numVectors );
246244 CentroidIterator centroidIterator = getCentroidIterator (fieldInfo , entry .numCentroids , entry .centroidSlice (ivfCentroids ), target );
247245 PostingVisitor scorer = getPostingVisitor (fieldInfo , entry .postingListSlice (ivfClusters ), target , acceptDocs );
248246
0 commit comments