[Enhancement] Reducing double vector reading and distance calculation for Disk based Filtered Vector Search #2215
Labels
Enhancements
Increases software capabilities beyond original client specifications
search-improvements
v2.19.0
Oppurtunity
Currently in plugin, whenever we are doing disk based vector search we first do a ANN search on quantized index and then do the rescoring using full precision vectors. ref:
k-NN/src/main/java/org/opensearch/knn/index/query/nativelib/NativeEngineKnnVectorQuery.java
Lines 64 to 75 in 7cf45c8
But this flow of first doing ANN search is not always true when efficient filters are present. For efficient filters we first see if exact search can be done or not. If exact search can be done then we do exact search rather than ANN search. ref:
k-NN/src/main/java/org/opensearch/knn/index/query/KNNWeight.java
Lines 132 to 156 in 7cf45c8
For disk based index, this exact search during filters first fetches the full precision vectors from disk, do binary quantization on them. ref:
k-NN/src/main/java/org/opensearch/knn/index/query/iterators/VectorIdsKNNIterator.java
Lines 91 to 101 in 7cf45c8
We would have to some changes in reduceToTopK function as with the above code scores of documents from different segments are not using same space_type. But I think that is still an easy problem to solve where we can just avoid the docs from the segments where hamming distance is not used.
We would need to do some benchmarks to see the performance differences. But I think in case of constraint envs, this can really help in reducing disk reads, and not necessary the distance computations.
The text was updated successfully, but these errors were encountered: