File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
server/src/main/java/org/elasticsearch/search/vectors Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1313import org .apache .lucene .search .knn .KnnSearchStrategy ;
1414import org .elasticsearch .index .codec .vectors .cluster .NeighborQueue ;
1515
16- public abstract class AbstractMaxScoreKnnCollector extends AbstractKnnCollector {
16+ /**
17+ * Abstract class for collectors that maintain a maximum score for KNN search.
18+ * It extends the {@link AbstractKnnCollector} and provides methods to manage
19+ * the minimum competitive document score, useful for tracking competitive scores
20+ * over multiple leaves.
21+ */
22+ abstract class AbstractMaxScoreKnnCollector extends AbstractKnnCollector {
1723 public static final long LEAST_COMPETITIVE = NeighborQueue .encodeRaw (Integer .MAX_VALUE , Float .NEGATIVE_INFINITY );
1824
1925 protected AbstractMaxScoreKnnCollector (int k , long visitLimit , KnnSearchStrategy searchStrategy ) {
2026 super (k , visitLimit , searchStrategy );
2127 }
2228
29+ /**
30+ * Returns the minimum competitive document score.
31+ * This is used to determine the global competitiveness of documents in the search.
32+ * This may be a competitive score even if the collector hasn't collected k results yet.
33+ *
34+ * @return the minimum competitive document score
35+ */
2336 public abstract long getMinCompetitiveDocScore ();
2437
38+ /**
39+ * Updates the minimum competitive document score.
40+ *
41+ * @param minCompetitiveDocScore the new minimum competitive document score to set
42+ */
2543 abstract void updateMinCompetitiveDocScore (long minCompetitiveDocScore );
2644}
Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ public int hashCode() {
4848 return Objects .hashCode (visitRatio );
4949 }
5050
51+ /**
52+ * This method is called when the next block of vectors is processed.
53+ * It accumulates the minimum competitive document score from the collector
54+ * and updates the accumulator with the most competitive score.
55+ * If the current score in the accumulator is greater than the minimum competitive
56+ * document score in the collector, it updates the collector's minimum competitive document score.
57+ */
5158 @ Override
5259 public void nextVectorsBlock () {
5360 if (accumulator == null ) {
You can’t perform that action at this time.
0 commit comments