In addition to providing an input vector to your query, you can also filter by vector metadata associated with every vector. Query results only include vectors that match filter criteria, meaning that filter is applied first, and topK results are taken from the filtered set.
By using metadata filtering to limit the scope of a query, you can filter by specific customer IDs, tenant, product category or any other metadata you associate with your vectors.
Supported operations
Optional filter property on query() method specifies metadata filter:
Operator
Description
$eq
Equals
$ne
Not equals
filter must be non-empty object whose compact JSON representation must be less than 2048 bytes.
filter object keys cannot be empty, contain " | . (dot is reserved for nesting), start with $, or be longer than 512 characters.
filter object non-nested values can be string, number, boolean, or null values.
Namespace versus metadata filtering
Both namespaces and metadata filtering narrow the vector search space for a query. Consider the following when evaluating both filter types:
A namespace filter is applied before metadata filter(s).
A vector can only be part of a single namespace with the documented limits. Vector metadata can contain multiple key-value pairs up to metadata per vector limits. Metadata values support different types (string, boolean, and others), therefore offering more flexibility.
The same query() method with a filter property supports metadata filtering.
Results with metadata filtering:
Limitations
Only newly created indexes on or after 2023-12-06 support metadata filtering. Previously created indexes cannot be migrated to support metadata filtering.