Skip to main content
Filtered semantic search combines vector similarity with metadata conditions. Results must be both semantically similar to your query and match your filter criteria. Use filtered search to narrow results by category, topic, date range, or other metadata attributes. VectorAI DB evaluates filters during search (pre-filtering), which is more efficient than filtering results after retrieval. Before running these examples, make sure you have a VectorAI DB instance running at localhost:6574 and the relevant SDK installed. For setup instructions, see Docker installation.

Keyword filter

Filter results by a specific keyword field value, such as topic or category:
The filter requires the topic field to equal "ml". In Python, use FilterBuilder with .must() to construct the condition. In JavaScript, use new Field('topic').eq('ml') directly. Only documents matching this condition are considered during vector similarity search.

Range filter

Filter results by a numeric range, such as documents from a specific year onward:
The gte operator on the year field restricts results to documents from 2023 onward. VectorAI DB evaluates this condition during search, so only qualifying documents are compared by vector similarity. Each result includes these fields:
  • id: The unique identifier of the matching document
  • score: Similarity score for documents that passed the filter
  • payload: Metadata object containing the filtered attributes
Create field indexes before running filtered searches (create_field_index in Python, createFieldIndex in JavaScript). Without indexes, VectorAI DB scans all points to evaluate filter conditions, which reduces performance. For the full filter syntax, see Filtering.