---
title: Range-Filtering Approximate Nearest Neighbor Search
url: https://www.emergentmind.com/topics/range-filtering-approximate-nearest-neighbor-search-rfanns
type: topic
---

# Range-Filtering Approximate Nearest Neighbor Search

Searching arXiv for recent and foundational RFANNS papers to ground the article.
Range-Filtering Approximate Nearest Neighbor Search (RFANNS) is a specialization of filtered approximate nearest neighbor search in which each data object couples a vector embedding with one or more ordered scalar attributes, and each query asks for nearest neighbors in vector space subject to numeric range predicates on those attributes. In the single-attribute form emphasized by much of the literature, the task is: given a query vector and a range \([l,r]\), retrieve the \(k\) nearest vectors whose associated scalar values lie in that range [2505.06501], [2402.00943]. More generally, RFANNS is naturally expressed in the vector–scalar hybrid data model, where a hybrid query combines a vector similarity function with a scalar filter \(f_s\), and range filtering corresponds to the case in which the active sub-filters are range constraints [2505.06501]. The problem sits at the intersection of high-dimensional approximate search, hybrid database execution, and range-aware index design, and has produced a diverse family of pre-filtering, post-filtering, hybrid, graph-based, tree-based, and learned approaches [2509.07789].

## 1. Formal model and relation to general FANNS

The survey literature formalizes a hybrid dataset as
\[
\mathcal{D} = \{(\mathbf{s}_1, \mathbf{v}_1), \dots, (\mathbf{s}_n, \mathbf{v}_n)\},
\]
where each point has a scalar tuple \(\mathbf{s}_i\) and a vector \(\mathbf{v}_i \in \mathbb{R}^d\) [2505.06501]. A scalar filter is a predicate
\[
f_s : \mathbb{S} \to \{0,1\},
\]
and the filtered subset is
\[
\mathcal{D}_{f_s} = \{\mathbf{p} \in \mathcal{D} \mid f_s(\mathbf{p}.\mathbf{s}) = 1\}
\]
[2505.06501]. A hybrid query is
\[
q = (f_s, f_v, \mathbf{v}_q, k),
\]
with scalar filter \(f_s\), vector similarity function \(f_v\), query vector \(\mathbf{v}_q\), and target result size \(k\) [2505.06501].

Within that framework, RFANNS is the case in which the scalar predicate is a range condition. For simplified scalar filters in disjunctive normal form,
\[
f_s(\mathbf{p}.\mathbf{s}) = \bigvee_{i=1}^{t}\left(\bigwedge_{j=1}^{m} f_{i,j}(\mathbf{p}.s_{j})\right),
\]
range filtering corresponds to active sub-filters of the form
\[
f_{i,j}(\mathbf{p}.s_j) =
\begin{cases}
1 & \text{if } l_{i,j} \le \mathbf{p}.s_j \le u_{i,j}, \\
0 & \text{otherwise}.
\end{cases}
\]
[2505.06501]. In the common single-attribute setting, each data object is \(o=(v,a)\), with \(v \in \mathbb{R}^d\) and a totally ordered numeric attribute \(a \in \mathbb{R}\), and an RFANN query is
\[
q=\langle v, I, k \rangle,
\]
where \(I=[a_l,a_r]\) is the numeric range predicate [2603.12913]. The objective is to return the \(k\) objects satisfying \(a_l \le o.a \le a_r\) that minimize \(\delta(q.v,o.v)\) [2603.12913].

A closely related formulation is the “\(c\)-approximate window search” model. There, each point has a numeric label \(\ell:V \to \mathbb{R}\), the query carries a window \((a,b)\), and the goal is to return \(y \in D_{(a,b)}\) such that
\[
dist_V(q,y) \le c \cdot dist_V(q,q^*)
\]
or \(\emptyset\) if \(D_{(a,b)}=\emptyset\) [2402.00943]. This is explicitly characterized as RFANNS with one numeric filter [2402.00943]. The literature also distinguishes top-\(k\) range-filtered retrieval from pure range retrieval, where the objective is to find all points within a distance radius \(r\),
\[
S_R(q,r) = \{x \in X : d(x,q) \le r\},
\]
a problem that becomes especially relevant when output size is highly variable [2502.13245].

Evaluation is usually centered on recall and efficiency. For filtered search, the standardized metric is
\[
\text{Recall@k} = \frac{|\mathcal{R} \cap \tilde{\mathcal{R}}|}{|\mathcal{R}|},
\]
where \(\mathcal{R}\) is the exact filtered result and \(\tilde{\mathcal{R}}\) is the approximate output [2505.06501]. The survey also fixes filter selectivity as
\[
\text{sel}_{f_s} = 1 - \frac{|\mathcal{D}_{f_s}|}{|\mathcal{D}|},
\]
so narrower ranges correspond to higher selectivity [2505.06501].

## 2. Query difficulty, selectivity, and distribution effects

RFANNS difficulty is not determined by range width alone. The survey literature emphasizes two orthogonal factors: selectivity and distribution factor [2505.06501]. Selectivity measures how many objects survive the range predicate, while the distribution factor characterizes the relationship between the vector distribution of the filtered subset and the distribution of queries. The survey names three regimes: **ID (In-Distribution)**, **OOD (Out-of-Distribution)**, and **POD (Partially Overlapping Distribution)** [2505.06501]. Queries whose selected scalar range aligns with the vector neighborhood are easier; cross-range queries in clustered datasets can be substantially harder even when selectivity is similar [2505.06501].

System-oriented work refines this with **Global Selectivity** and **Local Selectivity**. Given a filter predicate \(\phi\), global selectivity is
\[
\sigma_g = \frac{|\{v \in \mathcal{D} \mid \phi(v)=1\}|}{N},
\]
while local selectivity for a query \(q\) and its true \(k\)-NN set \(\mathcal{N}_q\) is
\[
\sigma_l = \frac{|\{v \in \mathcal{N}_q \mid \phi(v)=1\}|}{k}
\]
[2602.11443]. Their ratio
\[
r = \frac{\sigma_l}{\sigma_g}
\]
is normalized into the **GLS correlation**
\[
\rho_q = \frac{r - 1}{r + 1} \in [-1,1)
\]
[2602.11443]. Positive GLS means enrichment of valid points in the local neighborhood; negative GLS means depletion [2602.11443]. This system-level analysis matters because a range filter that is globally modest may still be locally hostile to graph traversal if valid neighbors are sparse in the natural vector neighborhood.

A related measure appears in WoW, which defines the fraction of in-range objects as \(f = n'/n\), where \(n'\) is the number of attributes in range, and then defines selectivity as
\[
s = \frac{1}{f} = \frac{n}{n'}
\]
[2508.18617]. WoW also uses RFANNS-specific **Local Intrinsic Dimensionality (LID)**:
\[
\mathrm{LID@k} = \mathbb{E}_{(v,R) \in Q} \left[ -\left( \frac{1}{k} \sum_{i=1}^{k} \log\frac{\delta(v,u_i)}{\delta(v,u_k)} \right)^{-1} \right]
\]
[2508.18617]. This suggests that RFANNS difficulty is jointly shaped by filter selectivity, vector geometry, and the degree to which the range predicate aligns with local neighborhood structure.

A common misconception is that narrower ranges are always easier because they leave fewer candidates. The system and survey evidence does not support that simplification. Narrow ranges can help pre-filtering, but they can also break graph navigability, produce candidate starvation in post-filtering, or create OOD workloads in which valid points are far from the unfiltered vector neighborhood [2505.06501], [2602.11443].

## 3. Algorithmic taxonomy

A unified benchmark organizes FANNS methods into **filter-then-search**, **search-then-filter**, and **hybrid-search** [2509.07789]. This taxonomy applies directly to RFANNS.

Filter-then-search first computes the filtered subset
\[
\mathcal{D}_f = \{x_i \in \mathcal{D} \mid f_i \mid_{\mathcal{S}} f_q\}
\]
and then runs ANN only on that subset [2509.07789]. For RFANNS, this means first retrieving all objects with \(a_i \in [l,r]\), then searching among them. The survey’s pruning taxonomy places this within **SSP** or **SJP**, depending on whether vector pruning is later introduced [2505.06501]. Pre-filtering is attractive when selectivity is high, but it can degenerate when the range is broad [2505.06501], [2602.11443].

Search-then-filter runs ANN on the full dataset to obtain a candidate set and filters afterward [2509.07789]. This is conceptually simple and widely used in vector databases, but the literature consistently notes that it deteriorates under high-selectivity ranges because many visited or returned candidates are out of range [2402.00943], [2509.07789], [2602.11443]. Post-filter HNSW and post-filter IVF-PQ are canonical examples [2509.07789].

Hybrid-search integrates filtering into the search or index itself [2509.07789]. In RFANNS, this includes segment-graph and range-aware graph designs that guide traversal toward in-range regions or reconstruct range-specific subgraphs [2409.02571], [2412.02448], [2504.04018]. The survey’s pruning-centric classification places SeRF and iRangeGraph under **VJP**, while WST is categorized as **SJP** [2505.06501].

Another important distinction is between single-index and multi-index designs. Classical pre-, post-, and in-filtering methods run against a generic ANN index, whereas dedicated RFANNS structures often materialize multiple range-specific graphs or graph fragments. This can improve query performance, but at the cost of substantial index blowup and maintenance complexity [2603.12913], [2604.20121]. Several later systems attempt to recover the benefits of range-aware indexing while reducing that blowup through structural reuse, learned penalties, or linear-space graph constructions [2511.04073], [2603.12913], [2604.20121].

## 4. Major index structures and search mechanisms

A major line of work uses range-dedicated graph organization. SeRF, described in survey and follow-up papers as a segment-graph approach, conceptually builds a graph for every possible interval \([a,b]\) over an ordered scalar domain, then overlays and compresses them so that, for any query range \([a,b]\), traversal behaves as if a dedicated graph had been built on
\[
\mathcal{D}_{[a,b]} = \{\mathbf{p} \in \mathcal{D} \mid a \le \mathbf{p}.s \le b\}
\]
[2505.06501]. Its worst-case space remains \(O(Mn^2)\) [2505.06501].

iRangeGraph improves this space profile by using a segment tree. Each tree node \(N\) corresponds to a scalar interval \([L(N),U(N)]\) and stores a graph \(G_N\) over
\[
\mathcal{D}_N = \{\mathbf{p} \mid L(N) \le \mathbf{p}.s \le U(N)\}
\]
[2505.06501]. A query range is covered by a minimal disjoint set of segment-tree nodes, their results are searched and merged, and overall space becomes \(O(Mn \log n)\) [2505.06501]. The original iRangeGraph paper presents the same design as an on-the-fly construction of a range-dedicated graph from **elemental graphs** stored at segment-tree nodes, with amortized edge-selection cost
\[
O(m + \log n)
\]
per object and total space
\[
O(nm\log n)
\]
[2409.02571].

WST and the \(\beta\)-Window Search Tree generalize the segment-tree idea into a modular framework. In the \(\beta\)-WST of “Approximate Nearest Neighbor Search with Window Filters,” one sorts the data by label, builds a multi-ary tree, and stores a full ANN index at each internal node [2402.00943]. For a query window \((a,b)\), the query algorithm descends into children whose label ranges intersect the window and directly queries a node’s ANN index whenever that node’s entire label range is contained in the window [2402.00943]. Theoretical runtime is
\[
O\Bigl( \beta \log_\beta N \cdot d + \beta \sum_{j=0}^{\log_\beta N} A_q(D, N \cdot \beta^{-j}) \Bigr)
\]
while preserving the base ANN approximation factor \(c\) [2402.00943]. WST variants such as Optimized Postfiltering, Three Split, and Super Postfiltering trade memory against blowup factor and query speed [2402.00943].

UNIFY takes a different route by constructing a unified proximity-graph-based index, SIG/HSIG, that supports pre-filtering, post-filtering, and hybrid filtering in one structure [2412.02448]. HSIG combines segmented HNSW-like graphs, skip-list links for pre-filtering, and bitmap-marked global edges for post-filtering [2412.02448]. Query execution uses range-aware strategy selection based on the estimated cardinality \(Y\) of the filtered subset: Strategy A when \(Y \le \tau_A\), Strategy B when \(Y \ge \tau_B\), and Strategy C otherwise [2412.02448].

ESG relaxes the exact-range reconstruction requirement. It defines an elastic factor \(e(R,[l,r])\) measuring how tightly a prebuilt superset range covers the query range and proves that controlled inclusion of out-of-range points does not compromise the bounded complexity of the search process [2504.04018]. This allows the use of at most two superset ranges per query instead of the \(O(\log N)\) exact decomposition used by existing methods [2504.04018]. The paper’s HBIO and HBIT structures then eliminate the \(O(\log N)\) query overhead inherent in prior reconstruction-based approaches [2504.04018].

WoW introduces **hierarchical window graphs** with varying window size \(G_l.w = o^l\) and a **window-to-window** mapping between query ranges and graph layers [2508.18617]. It uses a Weighted Balanced Tree for range cardinality and window computation, then selects a landing layer
\[
l_d = \arg\max_{l \in \{l_h, l_h+1\}} \frac{\min(2o^l, n')}{\max(2o^l, n')}
\]
so that graph window size matches the range size [2508.18617]. Query complexity is stated as
\[
O(\log n')
\]
with \(n'\) the in-range subset size [2508.18617].

RNSG pursues single-index graph design. It introduces the **Range-aware Relative Neighborhood Graph (RRNG)**, proves **monotonic searchability** and **structural heredity**, and then approximates RRNG with RNSG [2603.12913]. Structural heredity means that, for any query range \(I=[a_l,a_r]\), the induced subgraph \(G[I]\) is exactly the RRNG on the in-range nodes [2603.12913]. This motivates a single graph that can support arbitrary ranges without building many separate graphs [2603.12913].

For multi-attribute RFANNS, Garfield introduces a GPU-oriented **GMG** index. It partitions the dataset into \(S\) disjoint cells over a subset of partitioned attributes, builds local graph indexes inside each cell, and adds a constant number of inter-cell edges, giving total space
\[
O\big(n(d + lS)\big)
\]
[2604.20121]. This is explicitly presented as a response to the “severe index inflation and construction overhead” of previous RFANNS indices [2604.20121].

## 5. Learned and filter-aware scoring approaches

A separate line of work treats RFANNS and FANNS as a metric-learning problem rather than purely a structural indexing problem. In “Learning Filter-Aware Distance Metrics for Nearest Neighbor Search with Multiple Filters,” filtered ANN is formulated with discrete labels and the filter-aware distance
\[
D(q, v) = d(q, v) + w_m (1 - m(q, v)),
\]
where
\[
m(q, v) = \frac{|S_q \cap S_v|}{|S_q|}
\]
[2511.04073]. The scalar \(w_m\) is learned from training queries and ground-truth filtered neighbors using a constrained linear optimization problem with slack variables and a small margin \(\epsilon = 0.01\) [2511.04073]. The same paper explicitly maps this construction to RFANNS by proposing
\[
D_\text{RF}(q, v) = d(q, v) + \sum_\ell w_\ell \bigl(1 - m_\ell(q, v)\bigr),
\]
where each \(m_\ell\) is a predicate-satisfaction score for a range or label filter [2511.04073]. This suggests a data-driven alternative to hard range filtering or hand-tuned penalties.

FAVOR similarly modifies scoring, but does so at query time over a standard HNSW-style graph. It supports arbitrary filtering conditions, including range predicates and logical combinations, via an **exclusion distance**:
\[
\overline{Dis}(\mathbf{q}, \mathbf{v}) =
\begin{cases}
Dis(\mathbf{q}, \mathbf{v}^{T}), & A \in \mathcal{F}, \\
Dis(\mathbf{q}, \mathbf{v}^{N}) + D, & A \notin \mathcal{F},
\end{cases}
\]
[2605.07770]. The exclusion distance is chosen as
\[
D = \frac{1}{2p} (1-p) (\mathit{ef} - p) \Delta d
\]
with \(p\) the estimated selectivity and \(\Delta d\) a global average neighbor-distance parameter [2605.07770]. FAVOR also introduces a selectivity-driven search selector that routes low-selectivity queries to pre-filtering brute force and other queries to HNSW-based inline filtering [2605.07770]. Because its filtering model explicitly includes **Range** and **Logic**, it is directly applicable to RFANNS workloads [2605.07770].

These learned or reweighted methods differ from range-dedicated graph families in that they leave the underlying graph generic or only mildly modified. A plausible implication is that they trade some of the strong structural guarantees of dedicated range-aware graphs for greater flexibility under evolving predicates and heterogeneous workloads. The literature states that such approaches are particularly appealing when filter support must remain general and range predicates coexist with other structured conditions [2511.04073], [2605.07770].

## 6. Systems, benchmarks, and empirical trade-offs

The empirical literature repeatedly shows that RFANNS performance depends on workload composition, index design, and query execution policy. The WST paper reports up to a \(75\times\) speedup over existing solutions at the same level of recall on benchmark datasets with random labels, adversarial embeddings, and image search embeddings with real timestamps [2402.00943]. Its detailed results list speedups at recall \(\ge 0.95\) of up to \(75\times\) on Deep, \(16\times\) on SIFT, \(9\times\) on GloVe, and \(17\times\) on RedCaps, at the cost of significant offline memory and build overhead [2402.00943].

ESG reports performance improvements of \(1.5\times\) to \(6\times\) over state-of-the-art approaches while maintaining high accuracy [2504.04018]. WoW reports that, for index construction, its indexing time is on par with the most building-efficient index and \(4.9\times\) faster than the most query-efficient index with \(0.4\)-\(0.5\times\) smaller size, while for RFANNS query it is \(4\times\) faster than the most efficient incremental index and matches the performance of the best statically-built index [2508.18617]. RNSG reports significantly higher query performance with a more compact index and lower construction cost than existing state-of-the-art methods, and gives concrete examples such as SIFT1M at recall@10 \(=0.95\): RNSG \(5645\) QPS, iRangeGraph \(2805\) QPS, and UNIFY \(1401\) QPS [2603.12913].

System-level studies complicate the algorithmic picture. A vector-database analysis over FAISS, Milvus, and pgvector shows that engine behavior and optimizer decisions can dominate raw index characteristics [2602.11443]. It finds that Milvus achieves superior recall stability through hybrid approximate/exact execution, that pgvector’s optimizer frequently selects suboptimal execution plans, and that partition-based indexes such as IVFFlat can outperform graph-based indexes such as HNSW for low-selectivity queries [2602.11443]. In that work, highly selective range filters often favor exact fallback or partition-aware pruning, while graph-based post-filtering can fail to return enough valid neighbors unless search depth is increased [2602.11443].

Benchmarking work also notes that comparisons in FANNS have often been distorted by inconsistent parameter tuning, disparate workloads, and dataset-dependent implementation choices [2509.07789]. The resulting recommendation is not a single universally optimal RFANNS method, but a workload-sensitive choice among filter-then-search, search-then-filter, and hybrid-search, informed by selectivity, range width, \(k\), and dataset characteristics [2509.07789].

For multi-attribute RFANNS, Garfield extends the empirical frontier into GPU execution. It reports that its GPU-accelerated framework reduces index size by \(4.4\times\) while delivering \(119.8\times\) higher throughput than state-of-the-art RFANNS methods [2604.20121]. Because Garfield targets the multi-attribute setting where previous methods exhibit severe index inflation and CPU-bound execution, this result indicates that RFANNS research has moved beyond scalar single-attribute window search into hardware-aware, cell-partitioned, out-of-core architectures [2604.20121].

## 7. Limitations and research directions

Several limitations recur across the literature. Many classic RFANNS methods assume a **single numeric attribute** and simple interval predicates [2402.00943], [2505.06501], [2603.12913]. Extending segment graphs, tree decompositions, or range-aware proximity graphs to multiple attributes risks combinatorial or memory blowup [2505.06501], [2604.20121]. Dynamic updates are another persistent challenge: WST and many range-dedicated graph methods are primarily static, while incremental support in WoW and HSIG is comparatively recent [2412.02448], [2508.18617].

Another limitation is that strong graph-theoretic guarantees often come with substantial offline overhead. Exact RRNG construction is \(O(n^3)\), prompting approximations such as RNSG [2603.12913]. Segment-tree and range-dedicated graph schemes reduce online cost but can still consume several times the memory of a single ANN index [2402.00943], [2409.02571]. Learned penalty approaches avoid some of that duplication but introduce dependence on training queries and assumptions about the transferability of learned weights or selectivity models [2511.04073], [2605.07770].

The literature points to several future directions. One is richer predicate support: continuous ranges, hierarchical filters, interval predicates, and mixed logical conditions. The interval-predicate ANNS work on **Unified Dominance Graph (UDG)** shows how RFANNS ideas can be lifted from one-dimensional scalar ranges to closed two-bound conjunctive interval predicates by mapping interval relations into a two-dimensional dominance space [2606.24204]. Another direction is better workload-aware planning, combining range-specific indexes, generic ANN, and exact fallback according to learned estimates of selectivity, GLS, and distribution factor [2505.06501], [2602.11443], [2605.07770]. A further direction is hardware-aware RFANNS, where GPU execution, cell scheduling, and out-of-core streaming become first-class design parameters rather than implementation details [2604.20121].

A plausible implication of this trajectory is that RFANNS is evolving from a narrowly defined window-search problem into a broader family of hybrid retrieval tasks in which vector similarity, scalar predicates, execution planning, and hardware architecture are co-designed. The core problem, however, remains unchanged: retrieve nearest neighbors in vector space without losing the semantics or efficiency of numeric range filtering [2505.06501], [2402.00943].

Source: https://www.emergentmind.com/topics/range-filtering-approximate-nearest-neighbor-search-rfanns