Search with a metadata filter
The following code searches for the 3 records that are most semantically similar to a query and that have acategory metadata field with the value digestive system.
- Search with text
- Search with a vector
Searching with text is supported only for indexes with integrated embedding.
Metadata filter expressions
Pinecone’s filtering language supports the following operators:At the top level, list one or more fields (combined with implicit AND) or combine clauses with the logical operators
$and and $or. Use $not to negate a clause, as shown in the table. A bare comparison operator (like $gt) can’t appear at the top level; nest it under a field.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."genre" metadata field with a list of strings:
JSON
"genre" takes on both values, and requests with the following filters will match:
JSON
JSON
JSON
JSON
Text-match filters
On indexes with a document schema, three additional operators match text onstring fields that have full_text_search enabled. They narrow the candidate set before scoring, the same way metadata operators do.
These operators share a few rules:
- Where they apply. Fields declared with a
full_text_searchconfig object. - Tokenization. They reuse the field’s configured tokenizer and stemmer, so a token that matches in BM25 scoring will match in a text-match filter.
- Lucene-style operators. Phrase slop (
"phrase"~N), term boosting (^N), and phrase prefix ("phrase pre"*) are not parsed. Values are literal text and match semantics come from the operator name. To use those operators, score withquery_stringinstead. - Composition. They compose freely with metadata operators under
$and,$or, and$notat any nesting level: