Skip to main content
Guide
Use a source predicate to select the initial candidates and .where(...) for expression-based filtering later in a traversal. Vector prefiltering applies the same idea to similarity search by ranking only an exact traversal-defined candidate set.

Common predicates

Values can be literals or typed parameter expressions.

Filter a stream

Vector prefiltering

Vector prefiltering starts with a node or edge traversal, then ranks only the exact members of that stream. Use it when graph membership is a correctness boundary, such as “documents this user may access” or “products reachable from this category.” The execution order is graph traversal → exact candidate membership → vector ranking → top k. The traversal membership is authoritative. Approximate index structures may accelerate ranking, but a result outside the candidate set cannot be returned.

Rank a node stream

This request finds projects owned by the current user, ranks that exact set by embedding distance, and returns the top five.
This query requires an active three-dimensional cosine vector index on Project.embedding. Create and activate that index before running the request.
Use VectorSearchEdgesWithin in Go after an edge traversal. Rust, TypeScript, and Python select the node or edge wire operation from the current traversal state.

Requirements

  • Create a compatible vector index for the candidate label and property.
  • Match the index dimension exactly.
  • Use the same tenant partition value as the index when it is tenant-partitioned.
  • Preserve $distance in a projection before traversing away from a ranked hit.
  • Bound the candidate traversal when its size can grow without application limits.
Exact membership does not mean the vector engine exhaustively compares every candidate embedding. It means the final result is checked against the exact traversal set.

When to search without a prefilter

Use a source vector search when the whole indexed label and optional tenant partition is the intended candidate set. Use vector prefiltering when relationships, permissions, or earlier filters define membership.

Next steps

Typed parameters

Move request-specific filter values out of the AST.

Indexes

Back equality and range predicates with an index.

Vector indexes

Create the dimensioned index used for ranking.

Project search results

Preserve ranked hit metadata before continuing a traversal.