Skip to content

AbstractKnnVectorQuery breaks shallowAdvance contract, causing chaos #14857

@benwtrent

Description

@benwtrent

Description

When utilizing knn vector queries in Lucene v9 in a context that requires advanceShallow, it can break higher level logic, ending up causing infinite loops.

Specifically, if an upstream caller passes in NO_MORE_DOCS to bstractKnnVectorQuery.DocAndScoreQuery#advanceShallow it will blindly add context.docBase and execute a binary search, resulting in, potentially a doc ID other than NO_MORE_DOCS.

This issue appeared in a rather complex query mixing kNN results with required clauses in a ReqOptSumScorer

Version and environment details

Lucene v9

Bug does not exist in v10.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions