SURF: Substring Filtered Approximate Nearest Neighbor Search

Jiadong Xie, Hao Jiang, Yingfan Liu, Jeffrey Xu Yu, Hui Li, Jiangtao CuiarXiv 2026

TL;DR

Modern search often asks two very different questions at once: "Find me vectors semantically close to this query," and "Make sure their text metadata contains this exact substring." Existing hybrid systems either choke on massive memory footprints or waste cycles checking vectors that fail the text filter. ComSURF solves this by pairing a provably minimal string automaton with a dynamic programming algorithm that folds thousands of vector search graphs into a compact, blazingly fast index.

What Problem Does This Paper Address?

In high-dimensional data management, Approximate Nearest Neighbor (ANN) search finds items (like images or code) whose vector embeddings are closest to a query vector, typically by navigating a proximity graph (such as HNSW) where similar vectors are wired together.

In reality, users rarely want pure semantic similarity; they add hard constraints like substring filters—think grep-style code search or filtering product catalogs. Standard workarounds suffer from a "Goldilocks" selectivity dilemma:

  • Pre-filtering finds all matching strings first, then computes vector distances. If 30% of your database matches the substring, brute-forcing those distances tanks latency.
  • Post-filtering traverses the global vector graph first and checks strings afterward. If only 1% of items match, you spend almost all your time computing distances on dead ends.

Building a dedicated proximity graph for every possible substring guarantees fast searches, but is quadratic in string length and memory-prohibitive. A recent state-of-the-art index, VectorMaton, groups substrings using an Enhanced Suffix Automaton (ESA) and reuses indexes greedily. However, it distinguishes substrings by exact character positions—overkill when we only care which objects contain the string—and its greedy index-sharing leaves huge compression gains on the table while forcing queries to search and merge multiple sub-indexes.

Methods

The authors start with an idealized conceptual index (SURF) and compress it into a practical powerhouse (ComSURF) using three novel components:

  1. MultiSA (State-Minimized Suffix Automaton): Standard suffix automata group substrings by where they end in a text. MultiSA coarsens this: two substrings share a state if and only if they match the exact same set of objects now and under every possible character continuation. Proven to be the minimal deterministic automaton for this task, MultiSA strips away redundant states before a single vector graph is built.
Comparison of ESA, MultiSA, and the resulting Link Tree
  1. Link Tree & Dual Compression: Because a shorter suffix always matches a superset of the objects matched by a longer string (e.g., everything containing "abbb" also contains "bb"), MultiSA states naturally form a containment hierarchy called a Link Tree. ComSURF exploits this nested structure via two rules:
  2. Path Compression: Instead of building separate HNSW graphs along a parent-child chain, ComSURF builds one physical, versioned graph incrementally from child to parent. Edges are tagged with version labels indicating when they appear or get pruned, collapsing $m$ separate graphs into the footprint of one.
  3. Ancestor Compression: If a child state retains at least a fraction $\alpha$ (e.g., 30%) of its retained ancestor's vectors, ComSURF skips building its index altogether. At query time, it searches the ancestor's graph and post-filters—because post-filtering is actually great when selectivity is guaranteed to be high!
  4. Globally Optimal DP Planner & Wildcard Pruning: Deciding which states to skip, anchor, or merge along a path is a tricky combinatorial puzzle. The authors formulate an exact $O(m \log^2 m)$ dynamic programming algorithm that finds the globally optimal compression plan. They also extend search to SQL LIKE queries (_ and % wildcards), using the Link Tree to prune redundant search branches on the fly.

Datasets

The authors evaluate on 8 public datasets (ranging from ~157K to 1M vectors, and 128 to 1,024 dimensions):

  • Real-text metadata: arXiv and DBLP (paper titles embedded with SPECTER2), IMDB (names/occupations embedded with e5-large-v2), and Laion (image embeddings with native captions).
  • Synthetic strings: SIFT, GIST, Deep (image vectors), and Redcaps (image/text), paired with Zipf-distributed (plus Multinomial, Poisson, and Uniform) synthetic strings to stress-test controlled selectivities and distributions.

Key Insights and Ideas

  • Position blindness is a feature: Dropping character-position tracking from suffix automata shrinks the state space without losing an ounce of accuracy for boolean substring filtering, while still preserving suffix-containment trees.
  • Post-filtering isn't bad—uncontrolled selectivity is: By enforcing a strict mathematical floor ($\alpha = 0.3$) between a skipped state and its serving ancestor, ComSURF turns post-filtering from a liability into a surgical space-saving tool.
  • Tree-pruned wildcards: Normally, a % wildcard explodes across an automaton. In ComSURF, if state $p$ is a Link Tree ancestor of state $u$, $p$'s object set completely swallows $u$'s—even after future characters are appended. You can safely drop $u$ mid-query without missing a single valid neighbor.

Key Results

Across selectivities from 1% to 30%, ComSURF consistently dominates general filtered-ANN baselines (Milvus, VBASE, ACORN, OneSparse) and dedicated string-vector indexes:

  • Faster & Smaller than VectorMaton: ComSURF builds indexes 2.28–5.70× faster, shrinks index size by 1.78–3.42×, and still delivers up to 1.99× higher QPS (queries per second) at $\ge 0.95$ recall—largely because queries traverse a single logical graph rather than merging split indexes.
  • Massive gains over general baselines: At 20% selectivity and 0.99 recall, ComSURF is 20.5–53.1× faster than ACORN-1 and 3.2–13.5× faster than Post-filtering (jumping to 100.5× faster at 1% selectivity).
  • SQL LIKE dominance: On queries with _ and % wildcards, ComSURF achieves 2 to 3 orders of magnitude higher QPS than Milvus and VBASE, and over 10× higher QPS than VectorMaton on _ workloads.

Limitations and Future Work

  • Deletion overhead: While ComSURF inserts new items faster than VectorMaton using a delta layer, deletions are slower (tens of microseconds vs. near-zero) because ComSURF periodically consolidates and reconstructs its compression plan rather than relying purely on lazy tombstones. However, this extra work prevents the search-speed degradation seen in VectorMaton after heavy updates.
  • Manual hyperparameter tuning: Index size and search speed trade off via two thresholds: $\alpha$ (ancestor selectivity) and $ef_{\min}$ (the candidate size below which exact brute-force scanning replaces graph building). Right now these are set manually; the authors highlight automated, dataset-specific parameter tuning as a prime target for future work.

Summary updated

BibTeX
@misc{xie2026surf,
  author = {Jiadong Xie and Hao Jiang and Yingfan Liu and Jeffrey Xu Yu and Hui Li and Jiangtao Cui},
  title = {{SURF: Substring Filtered Approximate Nearest Neighbor Search}},
  year = {2026},
  eprint = {2611.36963},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.36963},
}
Figure