VectorIndexRetriever searches for the most semantically similar nodes to your query.
VectorStoreRetriever
TheVectorIndexRetriever is created from a VectorStoreIndex and performs similarity search using embeddings:
Similarity Search
Vector store retrievers use cosine similarity (or other distance metrics) to find the most relevant documents:Top-k Retrieval
Control the number of results returned with thesimilarityTopK parameter:
DEFAULT_SIMILARITY_TOP_K = 2
Filters and Metadata
Filter results based on metadata to narrow your search:Filter Operators
Supported filter operators:==- Equal to (default)!=- Not equal to>,<- Greater/less than (numbers)>=,<=- Greater/less than or equal (numbers)in- Value in arraynin- Value not in arrayany- Contains any (array fields)all- Contains all (array fields)text_match- Full text matchcontains- Array contains valueis_empty- Field is empty or doesn’t exist
Multiple Filters
Combine filters withAND or OR conditions:
Query Modes
Different query modes for specialized retrieval:Complete Example
Custom Parameters
Pass provider-specific parameters throughcustomParams:
Related Resources
- Retrieval Modes - Different retrieval strategies
- VectorStoreIndex - Building and managing vector indices
- Postprocessors - Reranking and filtering results