Filtered Approximate NN Search (FANNS)
- FANNS is a constrained retrieval method that integrates approximate nearest neighbor search with specific metadata filter conditions.
- It categorizes filtering mechanisms into pre-filtering, post-filtering, in-filtering, and hybrid approaches to address diverse query challenges.
- Its applications span recommendation systems, re-identification, and e-commerce search, balancing selectivity with speed and accuracy.
Filtered Approximate Nearest Neighbor Search (FANNS) is the problem of retrieving vectors that are nearest to a query in embedding space while also satisfying structured filter conditions on associated metadata or labels. A common formulation represents each item as , where is a -dimensional embedding and are attributes, and each query as , where is the query vector, is the requested result size, and is a filter function; the goal is to approximately retrieve the top- closest items satisfying (Iff et al., 29 Jul 2025). In a more compact constrained form, the exact objective is often written as 0 (Li et al., 22 Aug 2025). FANNS arises in retrieval-augmented generation, recommendation systems, vehicle/person re-identification, face and voice recognition, e-commerce search, and vector databases, where semantic similarity alone is insufficient without metadata validity (Iff et al., 29 Jul 2025).
1. Formal scope and filter semantics
The core distinction between ordinary ANNS and FANNS is that the nearest-neighbor objective is restricted to a filtered subset. In label-based formulations, each database vector may carry a label set 1 or 2, and the query carries a label condition 3 or 4. One common discrete multi-label semantics is AND-style filtering, where a candidate is valid only if 5 (Sutradhar et al., 6 Nov 2025). In broader benchmark formulations, supported filter types include exact match on a single attribute (EM), range filtering on an ordered attribute (R), exact match in set (EMIS), multi-attribute variants MEM, MR, MEMIS, and combined filters 6 using arbitrary logical operators (Iff et al., 29 Jul 2025).
The literature also treats several specialized subproblems as FANNS. Range-filtered ANNS (RFANN or RFANNS) restricts the candidate set by numeric intervals, typically over one or more ordered attributes; an RFANN query can be written as 7, where only objects with attributes in the interval are eligible (Zou et al., 13 Mar 2026). Multi-attribute range filtering generalizes this to conjunctions of intervals 8 over a subset of attributes (Yu et al., 17 Feb 2026). A more recent extension replaces scalar filters with graph-structured constraints: in ANNGR, each vector is associated with a node in a filter graph, and valid answers must satisfy 9 for a query node 0 and graph radius 1 (Tao et al., 1 Jul 2026).
A related but distinct usage appears in clustering-based ANN. There, “filtered” refers to a first-stage routing step that selects promising clusters before an exact or approximate within-cluster search. In that setting, the corpus is partitioned into 2 clusters, search is restricted to 3 clusters, and the routing function can itself be optimized as a ranking problem (Vecchiato, 2024). This suggests that FANNS terminology spans both metadata-constrained retrieval and internal filter-then-search architectures.
2. Taxonomic frameworks and recurring design abstractions
The modern literature does not rely on a single taxonomy. One common axis classifies methods by when filtering occurs: pre-filtering, post-filtering, in-filtering, and hybrid indexing. Pre-filtering first identifies items satisfying the predicate and then applies ANN on that subset; post-filtering runs ANN first and discards invalid results afterward; in-filtering integrates the predicate into traversal; hybrid indexing combines vector and attribute structure in a single index (Iff et al., 29 Jul 2025). A closely related benchmark taxonomy uses the operational families filter-then-search, search-then-filter, and hybrid-search (Shi et al., 9 Sep 2025). Database-oriented analysis introduces a similar tripartite distinction of pre-filtering, runtime-filtering, and post-filtering (Amanbayev et al., 11 Feb 2026).
A different abstraction classifies FANNS by its primary pruning mechanism rather than by filter timing. The pruning-focused survey distinguishes vector-solely pruning (VSP), vector-centric joint pruning (VJP), scalar-solely pruning (SSP), and scalar-centric joint pruning (SJP). In this view, FANNS performance depends on how vector pruning and scalar pruning are combined, not merely on whether filtering is applied before or after ANN traversal (Lin et al., 10 May 2025). This reclassification is motivated by the observation that two algorithms can both be “in-filtering” yet differ substantially in whether scalar constraints affect neighborhood expansion, result maintenance, or index construction.
A third axis classifies methods by their ANN substrate: tree-based, hash-based, graph-based, and quantization-based. This is especially useful because filter support and selectivity sensitivity often track the underlying index geometry. Range-filtering methods frequently exploit segmented edges or segmented subgraphs; label-filtering methods often rely on graph augmentation or label-aware distances; arbitrary filtering methods tend to emphasize subset identification, partitioning, or predicate-agnostic traversal (Li et al., 22 Aug 2025).
Terminology around selectivity remains inconsistent. Several benchmark papers define selectivity as the fraction of database items satisfying the filter, for example
4
which interprets low selectivity as a small matching subset (Iff et al., 29 Jul 2025). By contrast, the pruning-focused survey adopts
5
and argues that this should denote the fraction excluded by the filter, while the opposite convention is better called specificity (Lin et al., 10 May 2025). This terminological divergence is not merely stylistic, because comparative claims about “high” or “low” selectivity can invert across papers.
3. Core algorithmic paradigms
A large fraction of FANNS research centers on graph-based search under constrained navigation. Standard graph ANN relies on traversability of a proximity graph, but filtering removes vertices and can create sparse or disconnected induced subgraphs. This motivates label-aware edge construction, filter-aware traversal scores, special entry-point policies, or hybrid exact/approximate fallback mechanisms. In practical terms, the central difficulty is usually not only ranking valid points correctly, but reaching them efficiently when invalid points dominate local neighborhoods (Xu et al., 10 Feb 2026).
One influential direction learns a filter-aware distance rather than fixing a hand-tuned penalty. For multiple discrete labels, the learned scoring rule
6
adds a learned mismatch penalty 7 to the base vector distance and is used both in graph traversal and in graph construction. The same paper defines a data–data analogue
8
with an asymmetric Jaccard-style label similarity 9 for index construction (Sutradhar et al., 6 Nov 2025). This unifies search-time and build-time filter awareness.
A more general graph design is JAG, or Joint Attribute Graphs, which introduces separate build-time attribute distance 0 and query-time filter distance 1. For equality filters, for example,
2
For scalar range filters,
3
and 4 measures distance to the query interval. JAG uses these quantities in lexicographic comparators for graph construction and greedy search, and its Threshold-JAG variant merges edges produced under multiple attribute thresholds to remain robust across selectivity regimes and filter types (Xu et al., 10 Feb 2026).
FAVOR takes a related but explicitly selectivity-aware route. It keeps a standard HNSW-like graph, estimates query selectivity 5, and routes the query either to pre-filtering brute force when 6 or to a modified graph search otherwise, with 7 in the reported experiments. Its central mechanism is an exclusion distance: non-target data points receive an added penalty 8 in the adjusted distance
9
so invalid points remain available for connectivity but are pushed away in the traversal order (Song et al., 8 May 2026).
Other graph-based methods recast the navigation problem geometrically. Fiber-Navigable Search models the filtered induced subgraph as a fiber and computes local filtered-neighborhood density
0
and filtered drift
1
where 2, to decide when to remain inside the filtered neighborhood and when to revert to full-graph exploration. It classifies failures into topological cuts, geometric folds, and genuine basins, and handles all three with restarts in a fiber-present cluster identified by a lightweight anchor atlas (Dang, 31 Mar 2026).
Clustering-based ANN contributes a complementary first-stage filtering perspective. In an IVF-style pipeline, the dataset is partitioned into 3 clusters, one representative per cluster is indexed, and the routing function selects the top-4 clusters before within-cluster search. “Learning Cluster Representatives for Approximate Nearest Neighbor Search” recasts routing as a supervised learning-to-rank problem: the conventional centroid matrix 5 in 6 is replaced by a learned matrix 7 in 8, so representatives are optimized for routing quality rather than geometric averaging (Vecchiato, 2024).
Hashing-based FANNS remains relevant as well. Falconn++ augments cross-polytope LSH with locality-sensitive filtering inside hash buckets. After hashing, a point is retained in a bucket only if its projection on the query’s extreme random direction exceeds a threshold 9. The method is analyzed as a locality-sensitive filtering scheme that suppresses far-away points before expensive candidate evaluation, and is reported to improve recall-speed tradeoffs over standard Falconn while remaining competitive with HNSW in high-recall regimes (Pham et al., 2022).
4. Specialized subfields: range, multi-attribute, logical, and graph-structured filters
Numeric range filtering has produced some of the most structured theory in FANNS. “Approximate Nearest Neighbor Search with Window Filters” formalizes 0-approximate window search by attaching a real label 1 to each point and restricting retrieval to the subset 2. Its 3-Window Search Tree stores a standard ANN index at each internal node of a label-partition tree, so any ANN method can be transformed into a window-search index. The query algorithm either recurses into partially covered children or directly invokes the ANN index of a fully covered subtree, and the paper reports up to a 4 speedup over existing solutions at the same recall level (Engels et al., 2024).
A more graph-theoretic range solution is RNSG. The paper first defines the Range-aware Relative Neighborhood Graph (RRNG), whose edges depend on both spatial and attribute proximity: an edge 5 is absent if there exists a witness 6 that is closer to both 7 and 8 than they are to each other and whose attribute lies between theirs. RRNG is shown to satisfy monotonic searchability and structural heredity, meaning that a range-induced subgraph remains exactly the RRNG that would have been built on that range alone. RNSG is the practical approximation of this theory, and its reported results include higher query performance, smaller index size, and lower construction cost than prior RFANN methods (Zou et al., 13 Mar 2026).
Multi-attribute range filtering introduces combinatorial complexity that single-attribute methods do not address well. KHI combines an attribute-space partitioning tree with single-level HNSW graphs attached to tree nodes. Queries first route through the tree to obtain in-range entry points and then perform greedy graph search while reconstructing only in-range neighbors. The tree uses a skew-aware splitting rule that bounds height by 9, and the paper reports average QPS gains of 0 over the state-of-the-art baseline and up to 1 on a hard dataset, with larger gains for smaller selectivity, larger 2, and higher predicate cardinality (Yu et al., 17 Feb 2026).
Garfield addresses the same multi-attribute RFANNS setting from a GPU-systems perspective. Its GMG index partitions data into disjoint cells, builds a local CAGRA graph inside each cell, and adds only a constant number of inter-cell edges, yielding space complexity 3. Query processing uses cell selection, cluster-guided cell ordering, and a search–jump–search traversal that reuses candidates across cells; large datasets are handled by a cell-oriented out-of-core pipeline. The paper reports a 4 reduction in index size and up to 5 higher throughput than state-of-the-art RFANNS methods (Li et al., 22 Apr 2026).
Logical filters beyond conjunctions of simple predicates motivate cost-based planning. PathFinder converts a filter into disjunctive normal form, optimizes each conjunctive clause with a utility metric
6
when 7 covers 8, and then merges plans across clauses, optionally borrowing an index on one attribute to process a correlated predicate on another. It supports tree-based graph indexes for numeric predicates and hash-based graph indexes for categorical ones, and reports up to 9 higher query throughput at recall 0 than the best baseline (Wu et al., 2 Nov 2025).
Graph-structured filters form a newer branch of FANNS. In ANNGR, the filter requires results to lie within an 1-hop neighborhood in a predefined graph. DLH transforms this condition into distance-aware labeling sets 2 derived from Pruned Landmark Labeling and checks in-range status through simplified set intersections over pairs with 3. Large label sets are compressed with Bloom filters, and DLH-M memoizes query-side hashing. The paper reports throughput improvements of up to 4 while maintaining recall over 5 with limited extra storage (Tao et al., 1 Jul 2026).
5. Evaluation methodology, benchmark datasets, and workload dependence
Benchmarking has become a major research topic because FANNS results are highly sensitive to dataset construction, filter semantics, and tuning methodology. A central benchmark contribution is arxiv-for-fanns, built from embeddings of over 2.7 million arXiv abstracts using stella_en_400M_v5, producing normalized 4096-dimensional vectors and 11 real-world attributes including submitter, main_categories, authors, update_date, and number_of_versions. It provides small, medium, and large scales together with 10k EM, 10k R, and 10k EMIS queries per scale and precomputed ground truth (Iff et al., 29 Jul 2025).
Broader comparative studies reinforce that no single algorithm dominates. The transformer-embedding benchmark reports that ACORN supports arbitrary filter types and scales relatively well but is usually outperformed by more specialized methods; SeRF is excellent for ordered range filters but cannot handle categorical attributes; Filtered-DiskANN and UNG are strong on the medium-scale dataset but fail on the large-scale dataset; NHQ variants retain performance relatively well at scale but address AFANNS because they may return non-matching items. The paper’s main conclusion is explicit: no universally best FANNS method exists (Iff et al., 29 Jul 2025).
A separate in-depth experimental study proposes a unified FANNS interface and evaluates 10 algorithms and 12 methods across four datasets, using selectivity levels from 6 to 7. Its component analysis emphasizes the importance of pruning, entry-point selection, and edge-filtering costs. The study concludes that segmented subgraphs are especially effective for range filtering, label filtering remains underdeveloped, and arbitrary filtering is still hard despite ACORN’s flexibility (Li et al., 22 Aug 2025).
Systematic evaluation has also exposed the importance of parameter control. One unified benchmark organizes methods into filter-then-search, search-then-filter, and hybrid-search, explores more than 41,000 parameter combinations, and selects about 1,300 representative full-index parameter sets. Its empirical analysis shows that label length, filter selectivity, 8, dataset structure, and scalability each materially affect the QPS–Recall trade-off, and that methods that look strong at recall@1 can diverge substantially as 9 increases (Shi et al., 9 Sep 2025).
Workload hardness is not explained by selectivity alone. The survey of vector-scalar hybrid FANNS argues that query difficulty also depends on the distribution relationship between filtered subsets and query vectors, introducing in-distribution (ID), partially overlapping distribution (POD), and out-of-distribution (OOD) regimes. It uses UMAP and Mahalanobis distance to study this effect and concludes that selectivity plus distribution factor is a more informative axis than selectivity alone (Lin et al., 10 May 2025). A systems paper proposes a related per-query diagnostic, the Global-Local Selectivity correlation metric. With global selectivity
0
and local selectivity
1
it defines 2 and
3
so that 4 indicates enrichment of valid items near the query and 5 indicates depletion (Amanbayev et al., 11 Feb 2026).
6. Systems integration, practical implications, and open problems
In production vector databases, FANNS is shaped as much by execution architecture as by the underlying ANN index. A comparative analysis of FAISS, Milvus, and pgvector shows that the same HNSW or IVFFlat index can behave quite differently depending on whether filtering is implemented as pre-filtering, runtime-filtering, or post-filtering. The paper reports that Milvus achieves recall stability through hybrid approximate/exact execution, including dual-pool traversal and an adaptive brute-force fallback triggered around 93% filtered out; pgvector’s optimizer frequently prefers ANN-first plans even when exact sequential scans would give perfect recall at comparable latency; and IVFFlat can outperform HNSW for low-selectivity queries because cluster pruning becomes more effective than graph traversal (Amanbayev et al., 11 Feb 2026). This supports the broader systems claim that architecture and query planning can override raw index quality in filtered workloads.
Practical method selection is therefore workload-dependent. For arbitrary filters or mixed attribute types, flexible general-purpose methods such as ACORN or other predicate-agnostic graph designs are attractive, but they are not uniformly best (Iff et al., 29 Jul 2025). For ordered range filters, specialized range-aware structures such as SeRF, iRangeGraph, RNSG, KHI, or Garfield may be preferable, though the best choice depends on selectivity, construction budget, and hardware (Li et al., 22 Aug 2025). For low-selectivity arbitrary filters, routing between brute-force prefiltering and graph search, as in FAVOR, or engine-level fallback mechanisms, as in Milvus, is often decisive (Song et al., 8 May 2026).
The main open problems recur across surveys and benchmarks. Arbitrary filtering remains hard, especially outside narrow selectivity bands and outside carefully targeted predicate families (Li et al., 22 Aug 2025). Hyperparameter tuning is too important and still poorly automated (Li et al., 22 Aug 2025). Dynamic indexing is underexplored, particularly for range-aware and segmented structures (Li et al., 22 Aug 2025). Benchmark realism remains incomplete, motivating richer real-world attributes, correlated vector–metadata distributions, and standardized workloads (Iff et al., 29 Jul 2025). The hybrid-data survey adds workload-aware optimization, better query-difficulty metrics, and more general scalar-filter support to this list (Lin et al., 10 May 2025).
A plausible implication is that FANNS should no longer be viewed as a single algorithmic niche. The recent literature treats it as a family of constrained retrieval problems whose effective solution depends on filter semantics, selectivity regime, data–attribute correlation, hardware model, and optimizer behavior. That is why contemporary benchmark papers repeatedly conclude that there is no universally best method, only methods whose design assumptions align more or less well with the workload at hand (Iff et al., 29 Jul 2025).