Skip to main content
Multiconstraint search combines vector similarity with multiple metadata conditions. All conditions must be satisfied for a document to appear in results. Use multiconstraint search when a single filter is not specific enough. Chain multiple .must() conditions to narrow results by both category and range, or any combination of metadata fields. Before running this example, make sure you have a VectorAI DB instance running at localhost:6574 and the relevant SDK installed. For setup instructions, see Docker installation.
This example combines two filter conditions that both must be true:
  • topic == "ml" — Restricts results to the machine learning topic.
  • year >= 2024 — Restricts results to documents from 2024 onward.
In Python, chain .must() calls on FilterBuilder. In JavaScript, chain .and() calls on Field objects. Both conditions must be true for a document to be included. VectorAI DB evaluates all conditions 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 all filter conditions
  • payload: Metadata object containing the filtered attributes
You can combine any number of must, should, and must-not conditions in a single filter.
  • In Python, use .must(), .should(), and .must_not() on FilterBuilder.
  • In JavaScript, use .and(), .or(), and negation on Field objects.
For the full filter syntax and operator reference, see Filtering.