Skip to main content
Every record in an index must contain an ID and a dense or sparse vector. In addition, you can include metadata key-value pairs to store related information or context. When you search the index, you can then include a metadata filter to limit the search to records matching the filter expression.

Search with a metadata filter

The following code searches for the 3 records that are most semantically similar to a query and that have a category metadata field with the value digestive system.
Searching with text is supported only for indexes with integrated embedding.

Metadata filter expressions

Pinecone’s filtering language supports the following operators:
Only $and and $or are allowed at the top level of the query expression.
Each $in or $nin operator accepts a maximum of 10,000 values. Exceeding this limit will cause the request to fail. For more information, see Metadata filter limits.
For example, the following has a "genre" metadata field with a list of strings:
JSON
This means "genre" takes on both values, and requests with the following filters will match:
JSON
However, requests with the following filter will not match:
JSON
Additionally, requests with the following filters will not match because they are invalid. They will result in a compilation error:
JSON
JSON