KNN prefiltering in Manticore Search
Vector search rarely happens in isolation. You almost always have filters — a price range, a category, a date window, a geographic boundary. The question is: when do those filters get applied? The ...

Source: DEV Community
Vector search rarely happens in isolation. You almost always have filters — a price range, a category, a date window, a geographic boundary. The question is: when do those filters get applied? The answer makes a surprising difference in result quality. KNN prefiltering is available in Manticore Search starting from version 19.0.1. The problem with postfiltering Consider a product catalog with 10 million items. A user asks for the 10 nearest neighbors to a query vector, restricted to category = 'electronics'. With postfiltering, the KNN search runs first over the entire dataset, then the filter is applied to the results. If electronics make up 5% of the catalog, the graph explores nodes that are mostly irrelevant. Worse, many of the k nearest neighbors may not be electronics at all, so the final result set can be much smaller than requested. Ask for 10 results, get 2. This is the fundamental limitation of postfiltering: the HNSW graph doesn't know about your filters. It finds the closes