Skip to main content
Guide
Prefiltering ranks only the nodes or edges that a traversal reaches, instead of a whole index. Use it when graph membership is a correctness boundary, such as “documents this user may access” or “products reachable from this category.” It works the same way for vector and full-text search.

How it works

Every prefiltered search runs in the same order: graph traversal → exact candidate membership → ranking → top k.
  • The traversal is authoritative. A result outside the candidate set is never returned, even when approximate index structures accelerate ranking.
  • Output IDs are a deduplicated subset of the input IDs.
  • Each selected row keeps its bindings, path, and sack, with $distance (vector) or $score (text) attached.
  • Empty input returns without opening the index.
  • A tenant-partitioned index requires the same tenant value used to build the candidate stream.
Do not emulate prefiltering by searching the whole index and filtering afterward with .where(...). Excluded high-ranking hits still consume the top k, so the response can hold fewer than k eligible results. Build the candidate traversal first when membership matters.

Vector prefiltering

This request finds the projects a user owns, ranks that exact set by embedding distance, and returns the top five. It requires an active three-dimensional cosine vector index on Project.embedding.
Exact membership does not mean the engine compares every candidate embedding exhaustively. It means every returned hit is checked against the exact traversal set.

Full-text search prefiltering

This request finds the documents a user can read, ranks that exact set for "graph databases", and returns the top five. It requires an active text index on Document.body.
Results are identical to an exhaustive BM25 search of the tenant partition, intersected with the candidate IDs, followed by deterministic top-k selection: BM25 score descending, then entity ID ascending. BM25 statistics still come from the full tenant partition, not only the candidates.

SDK methods

Rust, TypeScript, and Python pick the node or edge wire operation from the current stream. Go has separate node and edge methods.

Result limits

Checklist

  • Create a compatible index for the candidate label and property. Vector queries must match the index dimension exactly.
  • Pass the same tenant value as the index when it is tenant-partitioned.
  • Project $distance or $score before traversing away from a ranked hit.
  • Bound the candidate traversal when its size can grow without application limits.

Next steps

Vector indexes

Create the dimensioned index used for ranking.

Text indexes

Create the BM25 index used for full-text ranking.

Traversals

Build the candidate set by following relationships.

Project search results

Preserve ranked hit metadata before continuing a traversal.