---
title: 'FANNS: Filtered Approximate Nearest Neighbor Search'
url: https://www.emergentmind.com/topics/fanns
type: topic
---

# FANNS: Filtered Approximate Nearest Neighbor Search

Searching arXiv for FANNS and related papers to ground the article in current literature.
arXiv_search(query="FANNS filtered approximate nearest neighbor search FPGA vector search", max_results=10)
FANNS most commonly denotes **Filtered Approximate Nearest Neighbor Search**, an extension of ANN retrieval in which the top-\(k\) vectors must be close to a query **and** satisfy structured attribute predicates over hybrid vector-scalar data [2505.06501] [2507.21989] [2509.07789] [2602.11443]. A distinct 2023 systems paper uses **FANNS** as the proper name of an **FPGA-accelerated Approximate Nearest Neighbor Search** framework for vector search on FPGAs [2306.11182]. The literature therefore uses the term both for a retrieval problem class and for a hardware system, with the former organizing most recent benchmark, taxonomy, and vector-database work.

## 1. Problem definition and formalization

In the problem-level usage, FANNS augments ordinary ANN search with metadata constraints. One formalization defines a database of items
\[
I_i = (v_i, a_{i,1}, \dots, a_{i,m}),
\]
where \(v_i\) is a \(d\)-dimensional embedding and \(a_{i,1},\dots,a_{i,m}\) are attributes, and a query
\[
Q_j = (q_j, k_j, f_j),
\]
where \(q_j\) is the query embedding, \(k_j\) is the requested result count, and \(f_j\) is a filter function over attributes [2507.21989]. A closely related survey formalizes a hybrid dataset as
\[
\mathcal{D} = \{(\mathbf{s}_{1}, \mathbf{v}_{1}), \dots, (\mathbf{s}_{n}, \mathbf{v}_{n})\},
\]
with scalar tuple \(\mathbf{s}_i \in \mathbb{S}\), vector \(\mathbf{v}_i \in \mathbb{R}^{d}\), scalar filter \(f_s : \mathbb{S} \rightarrow \{0,1\}\), and hybrid query
\[
q = (f_s, f_v, \mathbf{v}_q, k),
\]
where \(f_v\) is the vector similarity function [2505.06501].

The exact problem is to retrieve the nearest neighbors **among only the points that satisfy the filter**. The survey on vector-scalar hybrid data defines exact filtered nearest neighbor search over the filtered subset
\[
\mathcal{D}_{f_s} = \{\mathbf{p} \in \mathcal{D} \mid f_s(\mathbf{p}.\mathbf{s}) = 1\}
\]
and then treats FANNS as its approximate relaxation, typically evaluated by recall [2505.06501]. Another benchmark paper defines the FANNS goal as finding top-\(k\) points closest to a query that satisfy label constraints while ensuring both recall and QPS [2509.07789]. Some work also distinguishes **approximately filtered ANN search (AFANNS)**, where returned items may occasionally fail the filter [2507.21989].

The filter language varies across papers. One taxonomy uses **EM** (exact match), **R** (range), **EMIS** (exact match in set), **MEM**, **MR**, **MEMIS**, and **C** (combined filters) [2507.21989]. Another benchmark emphasizes **containment**, **overlap**, **equality**, and **fixed-length equality** predicates over label sets [2509.07789]. This suggests that FANNS is best understood as a family of constrained vector-retrieval problems rather than a single fixed query model.

## 2. Selectivity, query difficulty, and algorithmic taxonomies

A central quantity in FANNS is **selectivity**, but the literature uses two conventions. One paper defines selectivity as the fraction of the dataset satisfying the filter,
\[
\text{selectivity} = \frac{|\{I_i \mid I_i \in D \land f(I_i)=true\}|}{|D|},
\]
and interprets low selectivity as few items matching and high selectivity as many items matching [2507.21989]. The survey of vector-scalar hybrid data instead defines
\[
sel_{f_s} = 1 - \frac{|\mathcal{D}_{f_s}|}{|\mathcal{D}|},
\]
and explicitly notes that some papers use the opposite convention, which it says is better called **specificity** [2505.06501]. This terminological mismatch is one source of difficulty when comparing methods.

Recent work proposes several overlapping taxonomies. A method-oriented survey classifies approaches by **pre-filtering**, **post-filtering**, **in-filtering**, and **hybrid indexing** [2507.21989]. A unified benchmark restates the design space as **filter-then-search**, **search-then-filter**, and **hybrid-search** [2509.07789]. A separate survey argues that these categories are too coarse and introduces a pruning-focused framework: **VSP** (Vector-Solely Pruning), **VJP** (Vector-Centric Joint Pruning), **SSP** (Scalar-Solely Pruning), and **SJP** (Scalar-Centric Joint Pruning) [2505.06501].

Across these taxonomies, a shared claim is that filtering changes the optimization regime. One benchmark states that **pre-filtering is best when selectivity is low**, **post-filtering and in-filtering are best when selectivity is high**, and **hybrid indexing is best when selectivity is moderate** [2507.21989]. The pruning-focused survey adds that query difficulty is not determined by selectivity alone: the **distribution relationship** between query vectors and the filtered subset also matters, and it frames this as **ID**, **POD**, and **OOD** query regimes [2505.06501]. A plausible implication is that “hard” filtered queries can arise either because valid candidates are rare or because they are geometrically misaligned with the natural local neighborhood.

## 3. Benchmarks, datasets, and evaluation methodology

The benchmark literature repeatedly argues that older FANNS evaluations were fragmented, used synthetic attributes, or lacked modern embedding workloads [2507.21989] [2509.07789]. One 2025 benchmark introduces **arxiv-for-fanns**, derived from over 2.7 million arXiv abstracts, with a **4096-dimensional normalized embedding** generated by **stella_en_400M_v5** and **11 real-world attributes** including `submitter`, `main_categories`, `sub_categories`, `license`, `update_date`, and `authors` [2507.21989]. It provides three dataset scales—**small: 1k items**, **medium: 100k items**, and **large: over 2.7 million items**—together with **three sets of 10,000 queries** for **EM**, **R**, and **EMIS** filters [2507.21989].

A complementary systems paper introduces **MoReVec**, a relational benchmark with **Movies** and **Reviews** tables, **768-dimensional** \(L_2\)-normalized text embeddings generated using **gte-base-en-v1.5**, and metadata such as `year`, `genre`, `avgrating`, `numvotes`, `movierating`, `totalvotes`, and `quality` [2602.11443]. It is instantiated at three scales: **Small** with Movies \(= 9{,}999\) and Reviews \(= 247{,}286\), **Medium** with Movies \(= 99{,}560\) and Reviews \(= 1{,}496{,}493\), and **Large** with Movies \(= 551{,}155\) and Reviews \(= 2{,}598{,}267\) [2602.11443]. That paper evaluates **28,000 filtered kNN queries per dataset**, including unfiltered runs, under scalar-inequality predicates on `avgrating` and `totalvotes` [2602.11443].

A broader experimental benchmark uses **6 real-world datasets**—**arXiv**, **TripClick**, **LAION1M**, **YFCC**, **YouTube Audio**, and **YouTube Video**—and varies **Containment**, **Overlap**, **Equality**, and **Fixed-Length Equality** workloads, as well as query label length, selectivity, top-\(k\), and dataset size [2509.07789]. The survey of vector-scalar hybrid data reviews additional representative datasets such as **SIFT-1M**, **GIST-1M**, **Deep-10M**, **MNIST-8M**, **MTG**, **GloVe-Twitter**, **GloVe-Crawl**, **LAION-1M**, and **YouTube**, emphasizing variation in dimensionality, scale, and whether scalar attributes are synthetic or organic [2505.06501].

Evaluation is usually organized around **recall@k** and **QPS** [2507.21989] [2509.07789]. One systems paper extends **ANN-Benchmarks** to support filtered vector search [2602.11443]. Another introduces **Global-Local Selectivity (GLS)** to measure correlation between filters and local neighborhoods:
\[
\sigma_g = \frac{|\{v \in \mathcal{D} \mid \phi(v)=1\}|}{N}, \qquad
\sigma_l = \frac{|\{v \in \mathcal{N}_q \mid \phi(v)=1\}|}{k},
\]
\[
r = \frac{\sigma_l}{\sigma_g}, \qquad
\rho_q = \frac{r-1}{r+1}.
\]
It reports that mean GLS is near \(0\) on MoReVec across attributes and selectivities, implying that metadata is mostly independent of the embedding space in that benchmark [2602.11443].

## 4. Representative methods and empirical behavior

The method landscape is heterogeneous. A recent taxonomy and benchmark evaluates **ACORN**, **CAPS**, **FDANN** (Filtered-DiskANN), **NHQ** in **kgraph** and **nsw** variants, **UNG**, and **SeRF**, while also surveying **Rii**, **MA-NSW**, **PASE**, **AnalyticDB-V**, **Milvus**, **HQANN**, **AIRSHIP**, **HQI**, **VBASE**, **ARKGraph**, **\(\beta\)-WST**, **iRangeGraph**, and **UNIFY** [2507.21989]. A separate unified benchmark studies **Pre-filter Brute Force**, **ACORN-\(\gamma\)**, **ACORN-1**, **UNG**, **Post-filter HNSW**, **Post-filter IVFPQ**, **Filtered-DiskANN**, **Stitched-DiskANN**, **NHQ**, and **CAPS** [2509.07789].

No recent benchmark reports a universally dominant method. The arXiv-based benchmark explicitly concludes that **no single FANNS method is universally best** [2507.21989]. On its **medium-scale** dataset, **ACORN** is the only method applicable to all three benchmarked filter types, but it is generally outperformed by specialized methods; for **EM** filters the best methods are **NHQ (kgraph)**, **FDANN**, and **UNG**; for **EMIS**, **FDANN** performs especially well on transformer embeddings [2507.21989]. On the **large-scale** dataset, **ACORN**, both **NHQ** variants, and **SeRF** scale relatively well, whereas **FDANN**, **CAPS**, and **UNG** do not reach more than about **25% recall** in the benchmarked settings [2507.21989].

Method behavior also depends strongly on predicate type. The unified benchmark reports that **UNG** is the default strong choice for **containment** and **equality**, while **ACORN-1** or **Stitched-DiskANN** are preferable for **overlap** [2509.07789]. It further finds that **post-filter IVFPQ** degrades sharply as \(k\) increases, that **fixed-length equality** is relatively easy, and that very low selectivity is where algorithmic differences are most visible [2509.07789]. The survey of vector-scalar hybrid data similarly stresses that methods with strong scalar pruning are preferable under highly selective filters, whereas post-filtering can be adequate when filters are unselective [2505.06501].

Some methods are sharply specialized. **SeRF** is described as excellent for **range filtering on ordered attributes** but unable to handle categorical attributes in the same way as general-purpose methods [2507.21989]. **CAPS** offers the **fastest index construction** in one benchmark, but underperforms on transformer embeddings and drops at large scale [2507.21989]. **NHQ** scales well in some settings but is technically closer to **AFANNS** because it may return non-matching items [2507.21989]. This suggests that empirical comparisons must be conditioned on filter type, selectivity, vector geometry, and the exact correctness criterion.

## 5. Vector-database systems and execution strategies

A distinct research thread treats FANNS as a **system problem** inside vector databases rather than only an indexing problem [2602.11443]. That paper compares **FAISS**, **Milvus**, and **pgvector**, and systematizes **pre-filtering**, **runtime-filtering**, and **post-filtering** as generic execution strategies [2602.11443]. It explicitly excludes fusion methods such as **ACORN** and **HQANN** from that taxonomy because they are not schema-agnostic [2602.11443].

In this systems view, raw ANN index quality does not determine end-to-end behavior. **Milvus** is reported to achieve superior recall stability through **hybrid approximate/exact execution** and a **Dual-Pool traversal** strategy in which valid results and invalid navigation nodes are separated into different queues [2602.11443]. The same paper reports an adaptive fallback threshold around **93% filtered out**, at which point Milvus switches to brute-force search, preserving near-perfect or perfect recall at the cost of a latency floor [2602.11443]. **FAISS** is treated as a library baseline with an external boolean mask converted into a FAISS `IDSelector`, with overhead reported as **< 1 ms** on the large datasets [2602.11443].

The results are explicitly counter to standard ANN folklore in one important respect: **partition-based indexes (IVFFlat) outperform graph-based indexes (HNSW) for low-selectivity queries** [2602.11443]. The explanation given is that HNSW traversal cost dominates and the candidate queue can be starved when few valid points exist, whereas IVFFlat can exploit cluster pruning to skip large portions of the dataset [2602.11443]. The same paper also argues that **pgvector**’s cost-based optimizer frequently selects suboptimal plans, often favoring approximate vector-index scans even when exact filtered scans would yield perfect recall at comparable latency [2602.11443]. A plausible implication is that production FANNS performance depends at least as much on optimizer behavior and execution fallback as on the underlying ANN primitive.

## 6. FANNS as an FPGA vector-search framework

In a separate hardware paper, **FANNS** is the proper name of an **end-to-end and scalable vector search framework on FPGAs** [2306.11182]. Here the acronym does not denote filtered search; it denotes an FPGA accelerator that automatically **co-designs hardware and algorithm** for large-scale ANN retrieval under a user-provided recall target and FPGA resource budget [2306.11182]. The framework is built around **IVF-PQ**, optionally with **OPQ**, and models six query-time stages: **OPQ**, **IVFDist**, **SelCell**, **BuildLUT**, **PQDist**, and **SelK** [2306.11182].

The co-design problem couples algorithmic parameters—\(nlist\), \(nprobe\), \(K\), and \(OPQ_{enable}\)—with hardware allocation choices such as stage microarchitecture, numbers of processing elements, and memory placement [2306.11182]. FANNS enumerates valid hardware configurations under resource constraints
\[
\sum_{i} C_{r}(PE_i) + \sum_{i} C_{r}(FIFO_i) + C_{r}(infra) \leq Constraint_{r},
\]
uses a top-down throughput model
\[
QPS_{accelerator} = \min(QPS_s),
\]
and estimates single-PE throughput by
\[
QPS_{PE} = \frac{freq}{L+(N-1)\cdot II}
\]
to evaluate millions of combinations in about an hour [2306.11182].

The resulting architecture is a **deeply pipelined streaming design** with reusable hardware blocks for all six stages, FPGA-friendly **1-D array topology** within stages, alternative selection microarchitectures (**HPQ** and **HSMPQG**), and support for scale-out through a **hardware TCP/IP stack** [2306.11182]. On **SIFT100M** and **Deep100M**, the paper reports **up to \(23.0\times\) speedup over the fixed FPGA baseline** and **up to \(37.2\times\) speedup over CPU**; in an **eight-accelerator configuration**, it reports **\(5.5\times\)** better median latency and **\(7.6\times\)** better P95 latency than GPUs [2306.11182]. This hardware usage is conceptually adjacent to the broader FANNS retrieval problem, but it is a different referent: a co-designed ANN accelerator rather than a metadata-filtered query formalism.

## 7. Scope, ambiguity, and current significance

Recent arXiv usage therefore splits the term across at least two levels. At the **problem level**, FANNS is a constrained retrieval primitive central to RAG, recommendation, search, and vector databases, where semantic similarity must be combined with structured predicates [2507.21989] [2602.11443]. At the **system level**, FANNS can denote a specialized FPGA framework for ANN acceleration [2306.11182]. The literature also contains nearby but unrelated acronyms such as **FANS** and **FD-FANS** for fluid-antenna near-field systems, which are not part of filtered vector retrieval [2607.01300].

Across surveys, benchmarks, and systems studies, three high-level conclusions recur. First, **definitions and taxonomies matter**, because papers differ on filter semantics, selectivity conventions, and whether approximate filtering is allowed [2505.06501] [2507.21989]. Second, **no universally best method exists**; performance depends on filter type, selectivity, top-\(k\), dataset size, and embedding regime, especially with modern transformer embeddings [2507.21989] [2509.07789]. Third, **system integration is decisive**: query optimizers, fallback policies, and execution strategies can override raw index behavior [2602.11443]. This suggests that FANNS is best treated as a cross-layer research area spanning formal query models, index structures, workload-aware benchmarking, and deployment-specific systems design.

Source: https://www.emergentmind.com/topics/fanns