Search a document index
In a document index, you choose how to score each search with a clause inscore_by. Use an embed clause to search with text, or a dense_vector clause to search with a dense vector you generate yourself.
Search with text
To search with text, thestring field must declare embed, which enables integrated embedding. Pinecone embeds your query text with the field’s model. For example, this searches the chunk_text field of an index whose schema declares "chunk_text": {"type": "string", "embed": {}} and returns the 2 documents most semantically related to “Disease prevention”:
Search with a dense vector
To search adense_vector field, pass a dense_vector clause in score_by with the query’s dense vector. Generate the query vector with the same embedding model you used at upsert. For example, this searches the embedding field of the articles-hybrid schema, so the query vector must have 1536 dimensions:
Search a vector index
In a vector index, the query is either a dense vector or the ID of a record whose vector Pinecone uses as the query.Search with a dense vector
To search with a dense vector representation of a query, use the Search with a vector operation with the following parameters:- The
namespaceto query. To use the default namespace, set the namespace to"__default__". - The
vectorparameter with the dense vector values representing your query. - The
top_kparameter with the number of results to return. - Optionally, set
include_values,include_metadata, or both totrueto include the vector values, metadata, or both for the matching records in the response. For better performance, especially with highertop_kvalues, avoid including vector values unless you need them. See Decrease latency for more details.
example-namespace namespace:
Search with a record ID
When you search with a record ID, Pinecone uses the dense vector associated with the record as the query. Because search is approximate, the results aren’t guaranteed to include that record, even with a hightop_k. To retrieve a specific record, fetch it by ID. To search with a record ID, use the Search with a vector operation with the following parameters:
- The
namespaceto query. To use the default namespace, set the namespace to"__default__". - The
idparameter with the unique record ID containing the vector to use as the query. - The
top_kparameter with the number of results to return. - Optionally, set
include_values,include_metadata, or both totrueto include the vector values, metadata, or both for the matching records in the response. For better performance, especially with highertop_kvalues, avoid including vector values unless you need them. See Decrease latency for more details.
example-namespace namespace that are most semantically similar to the dense vector in the record:
Search a legacy integrated index
Legacy integrated indexes are created with
create_index_for_model and searched through the legacy Records API. For new indexes, declare embed on a string field in a document index instead. See Integrated embedding.- The
namespaceto query. To use the default namespace, set the namespace to"__default__". - The
query.inputs.textparameter with the query text. Pinecone uses the embedding model integrated with the index to convert the text to a dense vector automatically. - The
query.top_kparameter with the number of similar records to return. - Optionally, the
fieldsto return in the response. If you don’t specify any, the response includes all fields.