Skip to content

Conversation

@dungba88
Copy link
Owner

Description

Draft for two-phase vector search (see apache#13564). Created a new Query for sake of simplicity.

*
* @lucene.experimental
*/
public class TwoPhaseKnnVectorQuery extends KnnFloatVectorQuery {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would need a brand new query that doesn't build on top of AbstractKnnVectorQuery. Instead, gets passed the desired knn query as a parameter & the desired target then the outer reranking query can call the knn query via rewrite.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a cleaner idea actually. Let me try it in next rev.

Comment on lines 71 to 78
for (int i = 0; i < NUM_VECTORS; i++) {
float[] vector = randomFloatVector(VECTOR_DIMENSION, random);
Document doc = new Document();
doc.add(new IntField("id", i, Field.Store.YES));
doc.add(new KnnFloatVectorField(FIELD, vector, VECTOR_SIMILARITY_FUNCTION));
writer.addDocument(doc);
vectors.put(i, vector);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should flush the writers a few time to create more than one segments, this make sure the code path that results are merged from multiple segments are executed.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points, I added the flush() and uncovered/fixed a bug with doc ord.

@github-actions
Copy link

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog-check label to it and you will stop receiving this reminder on future updates to the PR.

@github-actions
Copy link

github-actions bot commented Jun 6, 2025

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Jun 6, 2025
@github-actions
Copy link

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog-check label to it and you will stop receiving this reminder on future updates to the PR.

@github-actions
Copy link

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog-check label to it and you will stop receiving this reminder on future updates to the PR.

@github-actions github-actions bot removed the Stale label Jun 13, 2025
@github-actions
Copy link

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants