You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Lu Xugang (Jira)" <ji...@apache.org> on 2022/05/05 01:55:00 UTC
[jira] [Comment Edited] (LUCENE-10397) KnnVectorQuery doesn't tie break by doc ID
[ https://issues.apache.org/jira/browse/LUCENE-10397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17531997#comment-17531997 ]
Lu Xugang edited comment on LUCENE-10397 at 5/5/22 1:54 AM:
------------------------------------------------------------
Hi [~msokolov@gmail.com] Could we back to use PriorityQueue, and add an Entry as below to do comparison:
{code:java}
public static class Entry {
final private int doc;
final private long nodeAndScore;
}
{code}
nodeAndScore still a encoding by node and score.
was (Author: chrislu):
Hi [~msokolov@gmail.com] Could we back to use PriorityQueue, and add a Entry as below to do comparison:
{code:java}
public static class Entry {
final private int doc;
final private long nodeAndScore;
}
{code}
nodeAndScore still a encoding by node and score.
> KnnVectorQuery doesn't tie break by doc ID
> ------------------------------------------
>
> Key: LUCENE-10397
> URL: https://issues.apache.org/jira/browse/LUCENE-10397
> Project: Lucene - Core
> Issue Type: Bug
> Reporter: Adrien Grand
> Priority: Minor
>
> I was expecting KnnVectorQUery to tie-break by doc ID so that if multiple documents get the same score then the ones that have the lowest doc ID would get returned first, similarly to how SortField.SCORE also tie-breaks by doc ID.
> However the following test fails, suggesting that it is not the case.
> {code:java}
> public void testTieBreak() throws IOException {
> try (Directory d = newDirectory()) {
> try (IndexWriter w = new IndexWriter(d, new IndexWriterConfig())) {
> for (int j = 0; j < 5; j++) {
> Document doc = new Document();
> doc.add(
> new KnnVectorField("field", new float[] {0, 1}, VectorSimilarityFunction.DOT_PRODUCT));
> w.addDocument(doc);
> }
> }
> try (IndexReader reader = DirectoryReader.open(d)) {
> assertEquals(1, reader.leaves().size());
> IndexSearcher searcher = new IndexSearcher(reader);
> KnnVectorQuery query = new KnnVectorQuery("field", new float[] {2, 3}, 3);
> TopDocs topHits = searcher.search(query, 3);
> assertEquals(0, topHits.scoreDocs[0].doc);
> assertEquals(1, topHits.scoreDocs[1].doc);
> assertEquals(2, topHits.scoreDocs[2].doc);
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org