vector data-type a new type of index was introduced.
A vector index is a dedicated index for indexing and searching through vectors.
To create this type of index use the following syntax:
Product nodes description attribute
use the following syntax:
Call relationships summary attribute
use the following syntax:
Understanding Vector Index Parameters
Required Parameters
- dimension: The length of the vectors to be indexed. Must match the dimensionality of your embeddings (e.g., 128, 384, 768, 1536).
- similarityFunction: The distance metric used for similarity search:
euclidean: Euclidean distance (L2 norm). Best for embeddings where magnitude matters.cosine: Cosine similarity. Best for normalized embeddings where direction matters more than magnitude.
Optional Parameters
These parameters control the HNSW (Hierarchical Navigable Small World) index structure:-
M (default: 16): Maximum number of connections per node in the graph
- Higher values improve recall but increase memory usage and build time
- Recommended range: 12-48
- Use 16-32 for most applications
-
efConstruction (default: 200): Number of candidates evaluated during index construction
- Higher values improve index quality but slow down indexing
- Recommended range: 100-400
- Use 200-300 for balanced quality/speed
-
efRuntime (default: 10): Number of candidates evaluated during search
- Higher values improve recall but slow down queries
- Can be adjusted per-query for speed/accuracy tradeoffs
- Recommended: Start with 10, increase if recall is insufficient
See Also
- Full-text Index — for keyword and text-based search
- Range Index — for numeric and string range queries
Tip: Use a vector index for semantic similarity search, a full-text index for keyword search, and a range index for exact or range-based property lookups.
Inserting vectors
To create a new vector use the vecf32 function as follows:Product node with a description attribute containing a vector.
Query vector index
Vector indices are used to search for similar vectors to a given query vector using the similarity function as a measure of “distance”. To query the index use eitherdb.idx.vector.queryNodes for node retrieval or
db.idx.vector.queryRelationships for relationships.
Product descriptions to a given query description vector
issue the following procedure call:
Deleting a vector index
To remove a vector index, simply issue thedrop index command as follows:
Index Management
Listing Vector Indexes
To view all indexes (including vector) in your graph, use:VECTOR and show the dimension and similarity function in the options field.
Verifying Vector Index Usage
To verify that a vector index is being used, examine the query execution plan:Performance Tradeoffs and Best Practices
When to Use Vector Indexes
Vector indexes are essential for:- Semantic search: Finding similar items based on meaning, not just keywords
- Recommendation systems: Discovering similar products, content, or users
- RAG (Retrieval Augmented Generation): Retrieving relevant context for LLMs
- Duplicate detection: Finding near-duplicate items based on embeddings
- Image/audio similarity: When using vision or audio embedding models
Performance Considerations
Benefits:- Enables efficient approximate nearest neighbor (ANN) search
- Scales to millions of vectors with sub-linear query time
- Supports both node and relationship vectors
- Memory usage: Vector indexes are memory-intensive
- A 1M vector index with 768 dimensions (float32) requires ~3GB of memory
- Formula:
vectors × dimensions × 4 bytes + HNSW overhead (~20%)
- Build time: Index construction can be slow for large datasets
- Approximate results: Returns approximate (not exact) nearest neighbors
- No support for filtering: Vector queries don’t combine well with property filters
- Choose appropriate vector dimensions (balance between quality and cost)
- Use cosine similarity for normalized embeddings (e.g., from OpenAI, Sentence Transformers)
- Use euclidean distance for unnormalized data
- Tune M and efConstruction based on your accuracy requirements
- Consider batch indexing for large datasets
- Monitor memory usage carefully
Similarity Function Tradeoffs
Cosine Similarity:- Best for: Text embeddings, normalized vectors
- Measures: Angular distance between vectors
- Range: -1 to 1 (1 = identical direction)
- Use when: Vector magnitude is not meaningful
- Best for: Unnormalized data, physical measurements
- Measures: Straight-line distance between vectors
- Range: 0 to ∞ (0 = identical)
- Use when: Both direction and magnitude matter
Example: Realistic Vector Search
Troubleshooting
Common Issues:- Dimension mismatch: Ensure all vectors have the same dimension as specified in the index
- Wrong similarity function: Use cosine for normalized vectors, euclidean for unnormalized
- Poor recall: Increase efRuntime or efConstruction parameters
- Slow queries: Decrease efRuntime or reduce k (number of results)
- High memory usage: Reduce M parameter or use lower-dimensional embeddings
Frequently Asked Questions
What similarity functions are supported for vector indexes?
What similarity functions are supported for vector indexes?
FalkorDB supports euclidean distance and cosine similarity. Use cosine for normalized vectors (e.g., from embedding models) and euclidean for unnormalized vectors.
How do I query a vector index?
How do I query a vector index?
Use
CALL db.idx.vector.queryNodes('Label', 'attribute', k, vecf32([...])) where k is the number of nearest neighbors to return and the last argument is your query vector.What vector dimensions are supported?
What vector dimensions are supported?
Vector indexes support any dimension, but all vectors for a given index must have the same dimension as specified during index creation. Mismatched dimensions will cause errors.
Can I create vector indexes on relationships?
Can I create vector indexes on relationships?
Yes. Use
CALL db.idx.vector.queryRelationships('RelType', 'attribute', k, query_vector) to perform similarity search on relationship vector properties.How do I improve vector search recall?
How do I improve vector search recall?
Increase the
efRuntime parameter for higher recall at the cost of query latency. For build-time quality, increase efConstruction and M parameters when creating the index.