benwtrent commented on code in PR #14274:
URL: https://github.com/apache/lucene/pull/14274#discussion_r1993097312
##########
lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java:
##########
@@ -646,6 +654,24 @@ public void testRandomWithFilter() throws IOException {
searcher.search(
getThrowingKnnVectorQuery("field",
randomVector(dimension), 1, filter4),
numDocs));
+
+ // Test a filter with cost slightly more than k, and check we use
exact search as k
+ // results are not retrieved from approximate search
+ Query filter5 = IntPoint.newRangeQuery("tag", lower, lower + 11);
+ results =
+ searcher.search(
+ getKnnVectorQuery("field", randomVector(dimension), 10,
filter5), numDocs);
+ assertEquals(10, results.totalHits.value());
+ assertEquals(results.totalHits.value(), results.scoreDocs.length);
+ expectThrows(
+ UnsupportedOperationException.class,
+ () ->
+ searcher.search(
+ getCappedResultsThrowingKnnVectorQuery(
+ "field", randomVector(dimension), 10, filter5, 5),
+ numDocs));
+ assertEquals(10, results.totalHits.value());
+ assertEquals(results.totalHits.value(), results.scoreDocs.length);
Review Comment:
I suspect this is flaky, have you ran this many times locally to detect any
weird edges?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]