Supported metadata types
You can associate a metadata payload with each vector in an index, as key-value pairs in a JSON object where keys are strings and values are one of:- String
- Number (integer or floating point, gets converted to a 64 bit floating point)
- Booleans (true, false)
- List of String
High cardinality consumes more memory: Pinecone indexes metadata to allow
for filtering. If the metadata contains many unique values — such as a unique
identifier for each vector — the index will consume significantly more
memory. Consider using selective metadata indexing to avoid indexing
high-cardinality metadata that is not needed for filtering.
for filtering. If the metadata contains many unique values — such as a unique
identifier for each vector — the index will consume significantly more
memory. Consider using selective metadata indexing to avoid indexing
high-cardinality metadata that is not needed for filtering.
Null metadata values are not supported. Instead of setting a key to hold a
null value, we recommend you remove that key from the metadata payload.
null value, we recommend you remove that key from the metadata payload.
JSON
Supported metadata size
Pinecone supports 40kb of metadata per vector.Metadata query language
Pinecone’s filtering query language is based on MongoDB’s query and projection operators. We currently support a subset of those selectors.
$eq
- Equal to (number, string, boolean)$ne
- Not equal to (number, string, boolean)$gt
- Greater than (number)$gte
- Greater than or equal to (number)$lt
- Less than (number)$lte
- Less than or equal to (number)$in
- In array (string or number)$nin
- Not in array (string or number)$exists
- Has the specified metadata field (boolean)
Using arrays of strings as metadata values or as metadata filters
A vector with metadata payload…JSON
"genre"
takes on both values.
For example, queries with the following filters will match the vector:
JSON
JSON
Inserting metadata into an index
Metadata can be included in upsert requests as you insert your vectors. For example, here’s how to insert vectors with metadata representing movies into an index:Querying an index with metadata filters
Metadata filter expressions can be included with queries to limit the search to only vectors matching the filter expression. For example, we can search the previous movies index for documentaries from the year 2019. This also uses theinclude_metadata
flag so that vector metadata is included in the response.
For performance reasons, do not return vector data and metadata when
top_k>1000
. Queries with top_k
over 1000 should not containinclude_metadata=True
or include_data=True
.More example filter expressions
A comedy, documentary, or drama:JSON
JSON
JSON
Deleting vectors by metadata filter
To specify vectors to be deleted by metadata values, pass a metadata filter expression to the delete operation. This deletes all vectors matching the metadata filter expression. Projects in thegcp-starter
region do not support deleting by metadata.
Example
This example deletes all vectors with genre “documentary” and year 2019 from an index.
Python JavaScript curl