Search with text
Searching with text is supported only for indexes with integrated embedding.
search_records
operation with the following parameters:
namespace
: The namespace to query. To use the default namespace, set to"__default__"
.query.inputs.text
: The query text. Pinecone uses the embedding model integrated with the index to convert the text to a sparse vector automatically.query.top_k
: The number of records to return.query.match_terms
: (Optional) A list of terms that must be present in each search result. For more details, see Filter by required terms.fields
: (Optional) The fields to return in the response. If not specified, the response includes all fields.
example-namespace
namespace:
Search with a sparse vector
To search a sparse index with a sparse vector representation of a query, use thequery
operation with the following parameters:
namespace
: The namespace to query. To use the default namespace, set to"__default__"
.sparse_vector
: The sparse vector values and indices.top_k
: The number of results to return.include_values
: Whether to include the vector values of the matching records in the response. Defaults tofalse
.include_metadata
: Whether to include the metadata of the matching records in the response. Defaults tofalse
.When querying withtop_k
over 1000, avoid returning vector data or metadata for optimal performance.
example-namespace
namespace:
Search with a record ID
When you search with a record ID, Pinecone uses the sparse vector associated with the record as the query. To search a sparse index with a record ID, use thequery
operation with the following parameters:
namespace
: The namespace to query. To use the default namespace, set to"__default__"
.id
: The unique record ID containing the sparse vector to use as the query.top_k
: The number of results to return.include_values
: Whether to include the vector values of the matching records in the response. Defaults tofalse
.include_metadata
: Whether to include the metadata of the matching records in the response. Defaults tofalse
.When querying withtop_k
over 1000, avoid returning vector data or metadata for optimal performance.
example-namespace
namespace that best match the sparse vector in the record:
Filter by required terms
This feature is in public preview and is available only on the
2025-10
version of the API. See limitations for details.- Precision filtering: Ensuring specific entities or concepts appear in results
- Quality control: Filtering out results that don’t contain essential keywords
- Domain-specific searches: Requiring domain-specific terminology in results
- Entity-based filtering: Ensuring specific people, places, or things are mentioned
match_terms
to your query, specifying the terms
to require and the strategy
to use. Currently, all
is the only strategy supported (all terms must be present).
For example, the following request searches for records about Tesla’s stock performance while ensuring both “Tesla” and “stock” appear in each result:
curl
match_terms
filter, you might get results like:
- “Tesla cars are popular in California” (mentions Tesla but not stock)
- “Stock market volatility affects tech companies” (mentions stock but not Tesla)
- “Electric vehicle sales are growing” (neither Tesla nor stock)
Limitations
- Integrated indexes only: Filtering by required terms is supported only for indexes with integrated embedding.
- Post-processing filter: The filtering happens after the initial query, so potential matches that weren’t included in the initial
top_k
results won’t appear in the final results - No phrase matching: Terms are matched individually in any order and location.
- No case-sensitivity: Terms are normalized during processing.