Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,26 @@ Same query with a Levenshtein distance of 3.

## Vector Similarity Search

Syntax Examples: `similar_to(predicate, 3, "[0.9, 0.8, 0, 0]")`
Syntax Examples:

Alternatively the vector can be passed as a variable: `similar_to(predicate, 3, $vec)`
```
similar_to(p_vec, 5, $vec) # here, $vec is a supplied query parameter
similar_to(vec, 3, "[0.9, 0.8, 0, 0]", ef: 128, distance_threshold: 0.5)`
```

This function finds nodes that have the named vector predicate (first parameter) similar to the provided vector (third parameter). The search is based on the distance metric specified in the [index](../predicate-indexing#vector-indices) (`cosine`, `euclidean`, or `dotproduct`).
The second parameter specifies the number of matches (top-k) be returned.

This function finds the nodes that have `predicate` close to the provided vector. The search is based on the distance metric specified in the index (`cosine`, `euclidean`, or `dotproduct`). The shorter distance indicates more similarity.
The second parameter, `3` specifies that top 3 matches be returned.
Two optional parameters control the accuracy and speed of the search:

* ef (search effort): Controls how many candidates the HNSW algorithm explores during search. Higher values improve recall (finding true nearest neighbors) at the cost of increased latency. Use this to tune the speed/accuracy tradeoff for individual queries when the index-level `efSearch` default doesn't fit your needs
* distance_threshold: Filters results to only return vectors within the specified distance (for euclidean) or above the specified similarity score (for cosine/dot product). Use this when you need results that meet a minimum quality threshold rather than just the top-k nearest. Note: Since filtering is applied after the top-k search (second parameter), specifying a small topk may limit the pool of candidates before filtering, potentially returning fewer results than expected. Consider increasing topk when using distance_threshold to ensure enough candidates are evaluated.

Schema Types: `float32vector`

Index Required: `hnsw`



## Full-Text Search

Syntax Examples: `alloftext(predicate, "space-separated text")` and `anyoftext(predicate, "space-separated text")`
Expand Down