Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,20 @@ private static CentroidIterator getCentroidIteratorWithParents(
final NeighborQueue currentParentQueue = new NeighborQueue(maxChildrenSize, true);
final int bufferSize = (int) Math.min(Math.max(centroidRatio * numCentroids, 1), numCentroids);
final int numCentroidsFiltered = acceptCentroids == null ? numCentroids : acceptCentroids.cardinality();
if (numCentroidsFiltered == 0) {
// TODO maybe this makes CentroidIterator polymorphic?
return new CentroidIterator() {
@Override
public boolean hasNext() {
return false;
}

@Override
public CentroidOffsetAndLength nextPostingListOffsetAndLength() {
return null;
}
};
}
final float[] scores = new float[ES92Int7VectorsScorer.BULK_SIZE];
final NeighborQueue neighborQueue;
if (acceptCentroids != null && numCentroidsFiltered <= bufferSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.lucene.index.VectorEncoding;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.lucene.search.AcceptDocs;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.KnnCollector;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TopKnnCollector;
Expand Down Expand Up @@ -382,6 +383,13 @@ private void doRestrictiveFilter(boolean dense) throws IOException {
uniqueDocIds.add(topDocs.scoreDocs[i].doc);
}
assertEquals(matchingDocs, uniqueDocIds.size());
// match no docs
leafReader.searchNearestVectors(
"f",
vector,
new TopKnnCollector(2, Integer.MAX_VALUE),
AcceptDocs.fromIteratorSupplier(DocIdSetIterator::empty, leafReader.getLiveDocs(), leafReader.maxDoc())
);
}
}
}
Expand Down