I'm trying to understand how to best implement a pre-filtered KNN vector search. To be clear: I'd like to pre-filter the total number of docs down to a smaller set, and then run a vector search that leverages a vector index over the results.
Documentation describes a Filtered KNN Search with the following note: "The filter is applied during the approximate kNN search to ensure that k matching documents are returned."
The during phrase is unclear.
Does this mean that it will apply a per-shared pre-filter?
Or does this mean that it will do a KNN search on the all the data in the shard and then filter before the share returns results.. possibly getting more results if too many got filtered out?
If a filter is applied to a KNN search, Is the underlying vector index still being used or it is reverting to brute force?
Apologies it was unclear. We can update the verbiage.
Does this mean that it will apply a per-shared pre-filter?
It means that it is a pre-filter applied while searching the individual HNSW graphs. So, it is a true pre-filter while still only searching for the kNN within the HNSW graph.
Or does this mean that it will do a KNN search on the all the data in the shard and then filter before the share returns results..
No, it does not do that, it would be very expensive to do that.
The only time we dynamically switch to brute force is when the filter set is very restrictive (less than num_candidates).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.