Search with a vector
Search a namespace using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores.
For guidance, examples, and limits, see Search.
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"
curl "https://$INDEX_HOST/query" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-Api-Version: 2026-07" \
-d '{
"namespace": "example-namespace",
"vector": [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
"filter": {"genre": {"$eq": "documentary"}},
"topK": 3,
"includeValues": true
}'POST /query
{
"results": [
{
"matches": [
null
],
"namespace": "example-namespace"
}
],
"matches": [
{
"id": "example-vector-1",
"score": 0.08,
"values": [
0.1,
0.2,
0.3,
0.4,
0.5,
0.6,
0.7,
0.8
],
"sparseValues": {
"indices": [
1,
312,
822,
14,
980
],
"values": [
0.1,
0.2,
0.3,
0.4,
0.5
]
},
"metadata": {
"genre": "documentary",
"year": 2019
}
}
],
"namespace": "<string>",
"usage": {
"readUnits": 5,
"egressBytes": 1024
}
}{
"code": 123,
"message": "<string>",
"details": [
{
"typeUrl": "<string>",
"value": "<string>"
}
]
}{
"code": 123,
"message": "<string>",
"details": [
{
"typeUrl": "<string>",
"value": "<string>"
}
]
}{
"code": 123,
"message": "<string>",
"details": [
{
"typeUrl": "<string>",
"value": "<string>"
}
]
}Authorizations
Section titled “Authorizations”Api-KeystringrequiredAn API Key is required to call Pinecone APIs. Get yours from the console.
Headers
Section titled “Headers”X-Pinecone-Api-VersionstringrequiredRequired date-based version header
namespace?stringThe namespace to query.
Example: example-namespace
topKintegerrequiredThe number of results to return for each query.
Required range: 1 <= x <= 10000. Example: 10
filter?objectThe filter to apply. You can use vector metadata to limit your search. See Understanding metadata.
includeValues?booleanIndicates whether vector values are included in the response. For on-demand indexes, setting this to true may increase latency, especially with higher topK values, because vector values are retrieved from object storage. Unless you need vector values, set this to false for better performance.
Example: true
includeMetadata?booleanIndicates whether metadata is included in the response as well as the ids.
Example: true
vector?number[]The query vector. This should be the same length as the dimension of the index being queried. Each query request can contain only one of the parameters id or vector. Whether vector and sparseVector may be sent together depends on the index: an index that supports only a single query predicate rejects the combination.
sparseVector?objectVector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
Show child attributes
indicesinteger[]requiredThe indices of the sparse data.
valuesnumber[]requiredThe corresponding values of the sparse data, which must be with the same length as the indices.
id?stringThe unique ID of the vector to be used as a query vector. It is mutually exclusive with both vector forms: a request naming id may not also carry vector or sparseVector.
Required string length: 1 - 512. Example: example-vector-1
scanFactor?numberAn optimization parameter for IVF dense indexes in dedicated read node indexes. It adjusts how much of the index is scanned to find vector candidates. Range: 0.5 – 4 (default). Keep the default (4.0) for the best search results. If query latency is too high, try lowering this value incrementally (minimum 0.5) to speed up the search at the cost of slightly lower accuracy. This parameter is only supported for dedicated (DRN) dense indexes.
Required range: 0.5 <= x <= 4. Example: 2
maxCandidates?integerAn optimization parameter that controls the maximum number of candidate dense vectors to rerank. Reranking computes exact distances to improve recall but increases query latency. Range: top_k – 100000. Keep the default for a balance of recall and latency. Increase this value if recall is too low, or decrease it to reduce latency at the cost of accuracy. This parameter is only supported for dedicated (DRN) dense indexes.
Required range: 1 <= x <= 100000. Example: 1000
Response
Section titled “Response”200 — A successful response.
The response for the query operation. These are the matches found for a particular query vector. The matches are ordered from most similar to least similar.
results?object[]deprecatedDEPRECATED. The results of each query. The order is the same as QueryRequest.queries.
Show child attributes
matches?object[]The matches for the vectors.
Show child attributes
idstringrequiredThis is the vector's unique id.
Required string length: 1 - 512. Example: example-vector-1
score?numberThis is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.
Example: 0.08
values?number[]This is the vector data, if it is requested.
sparseValues?objectVector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
Show child attributes
indicesinteger[]requiredThe indices of the sparse data.
valuesnumber[]requiredThe corresponding values of the sparse data, which must be with the same length as the indices.
metadata?objectThis is the metadata, if it is requested.
namespace?stringThe namespace for the vectors.
Example: example-namespace
matches?object[]The matches for the vectors.
Show child attributes
idstringrequiredThis is the vector's unique id.
Required string length: 1 - 512. Example: example-vector-1
score?numberThis is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.
Example: 0.08
values?number[]This is the vector data, if it is requested.
sparseValues?objectVector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
Show child attributes
indicesinteger[]requiredThe indices of the sparse data.
valuesnumber[]requiredThe corresponding values of the sparse data, which must be with the same length as the indices.
metadata?objectThis is the metadata, if it is requested.
namespace?stringThe namespace that served the query: the request's namespace, or the alias's target namespace when the request named a namespace alias.
usage?objectShow child attributes
readUnits?integerThe number of read units consumed by this operation.
Example: 5
egressBytes?integerThe billed egress for this response, in bytes. Measured on the encoded response payload.
Required range: 0 <= x. Example: 1024