Cortex implements hybrid search that combines three search methods for optimal results: vector similarity, keyword matching, and knowledge graph traversal.
Search Methods
Vector Search (Semantic)
Uses embedding similarity to find conceptually related content, even with different wording.
- Powered by OpenAI text-embedding-3-small (1536 dimensions)
- Stored and queried via Neo4j's native vector index
- Finds related concepts, synonyms, and paraphrases
Keyword Search (Full-Text)
Traditional full-text search for exact term matching.
- Uses Neo4j's full-text indexes
- Great for specific terms, names, and codes
- Supports phrase matching
Graph Traversal
Follows relationships in the knowledge graph to find connected information.
- Traverses up to 2 hops from matched entities
- Finds related entities even if not mentioned in the query
- Leverages GraphRAG entity extraction
Hybrid Search Architecture
API Usage
Basic Search
Code
Response
Code
Advanced Search
Code
Search Types
| Type | Description | When to Use |
|---|---|---|
hybrid | All methods combined (default) | General queries |
vector | Semantic search only | Conceptual/abstract queries |
keyword | Full-text search only | Exact term matching |
graph | Graph traversal only | Relationship exploration |
Reciprocal Rank Fusion (RRF)
Cortex uses RRF to combine results from multiple search methods:
Code
Where:
kis a constant (default: 60)rank(d)is the position in each result list
The weights for each method are configurable:
Code
Cross-Encoder Re-ranking
After RRF fusion, a cross-encoder model re-ranks the top candidates for higher precision:
- Model:
cross-encoder/ms-marco-MiniLM-L-6-v2 - Considers query-document pairs together
- Significantly improves relevance of top results
Enable/disable via:
Code
Collection-Scoped Search
By default, search queries span all collections. To narrow results to a specific collection, pass collection_id:
Code
Graph Context in Search
When graph search is enabled, results may include entity relationships:
Code
Performance Tips
- Use collection scoping when needed - Search spans all collections by default; narrow to a specific collection for focused results
- Adjust weights - Tune
VECTOR_WEIGHT,KEYWORD_WEIGHT,GRAPH_WEIGHTfor your use case - Limit results - Start with smaller limits and paginate
- Enable re-ranking - Improves precision for the final results