jpountz commented on code in PR #12434: URL: https://github.com/apache/lucene/pull/12434#discussion_r1273669221
########## lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsReader.java: ########## @@ -117,6 +118,71 @@ public abstract TopDocs search( */ public abstract TopDocs search( String field, byte[] target, int k, Bits acceptDocs, int visitedLimit) throws IOException; + + /** + * Return the k nearest neighbor documents as determined by comparison of their vector values for + * this field, to the given vector, by the field's similarity function. The score of each document + * is derived from the vector similarity in a way that ensures scores are positive and that a + * larger score corresponds to a higher ranking. + * + * <p>The search is allowed to be approximate, meaning the results are not guaranteed to be the + * true k closest neighbors. For large values of k (for example when k is close to the total + * number of documents), the search may also retrieve fewer than k documents. + * + * <p>The returned {@link TopDocs} will contain a {@link ScoreDoc} for each nearest neighbor, in + * order of their similarity to the query vector (decreasing scores). The {@link TotalHits} + * contains the number of documents visited during the search. If the search stopped early because + * it hit {@code visitedLimit}, it is indicated through the relation {@code + * TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO}. + * + * <p>The behavior is undefined if the given field doesn't have KNN vectors enabled on its {@link + * FieldInfo}. The return value is never {@code null}. + * + * @param field the vector field to search + * @param target the vector-valued query + * @param knnResults a KnnResults collector and relevant settings for gathering vector results + * @param acceptDocs {@link Bits} that represents the allowed documents to match, or {@code null} + * if they are all allowed to match. + * @return the k nearest neighbor documents, along with their (similarity-specific) scores. + */ + public TopDocs search(String field, float[] target, KnnResults knnResults, Bits acceptDocs) + throws IOException { + throw new UnsupportedOperationException( + "vector reader doesn't provide KNN search with results provider"); Review Comment: My point of view on `LeafReader` and other related classes is that we should avoid breaking callers, but it's fine to break folks who extend these classes - as the latter is very expert usage of Lucene. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org