File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
java/org/apache/lucene/search
test/org/apache/lucene/search Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -256,6 +256,11 @@ static VectorSimilarityScorer fromAcceptDocs(
256256 new FilteredDocIdSetIterator (acceptDocs ) {
257257 @ Override
258258 protected boolean match (int doc ) throws IOException {
259+ // Advance the scorer
260+ if (!scorer .advanceExact (doc )) {
261+ return false ;
262+ }
263+
259264 // Compute the dot product
260265 float score = scorer .score ();
261266 cachedScore [0 ] = score * boost ;
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ public boolean advanceExact(int doc) throws IOException {
8787
8888 @ Override
8989 public float score () throws IOException {
90+ assert values .docID () != -1 : getClass ().getSimpleName () + " is not positioned" ;
9091 return similarity .compare (query , values .vectorValue ());
9192 }
9293 }
@@ -117,6 +118,7 @@ public boolean advanceExact(int doc) throws IOException {
117118
118119 @ Override
119120 public float score () throws IOException {
121+ assert values .docID () != -1 : getClass ().getSimpleName () + " is not positioned" ;
120122 return similarity .compare (query , values .vectorValue ());
121123 }
122124 }
Original file line number Diff line number Diff line change @@ -433,8 +433,8 @@ public void testFallbackToExact() throws IOException {
433433
434434 public void testApproximate () throws IOException {
435435 // Non-restrictive filter, along with similarity to visit a small number of nodes
436- int numFiltered = random (). nextInt ( numDocs - ( numDocs * 4 ) / 5 ) + ( numDocs * 4 ) / 5 ;
437- int targetVisited = random ().nextInt (numFiltered / 8 - numFiltered / 10 ) + numFiltered / 10 ;
436+ int numFiltered = numDocs - 1 ;
437+ int targetVisited = random ().nextInt (numFiltered / 10 - 1 ) + 1 ;
438438
439439 V [] vectors = getRandomVectors (numDocs , dim );
440440 V queryVector = getRandomVector (dim );
You can’t perform that action at this time.
0 commit comments