---
title: "Search with a vector"
method: POST
path: "/query"
tags: ["Vector Operations"]
---

# Search with a vector

`POST /query`

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](https://docs.pinecone.io/guides/search/search-overview).

## Headers

- `X-Pinecone-Api-Version` string, required

## Request body

- DbDataQueryRequest — The request for the `query` operation.
  - `namespace` string — The namespace to query.
  - `topK` integer, required — The number of results to return for each query.
  - `filter` object — The filter to apply. You can use vector metadata to limit your search. See [Understanding metadata](https://docs.pinecone.io/guides/index-data/indexing-overview#metadata).
  - `includeValues` boolean — Indicates 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.
  - `includeMetadata` boolean — Indicates whether metadata is included in the response as well as the ids.
  - `queries` DbDataQueryVector[] — DEPRECATED. Use `vector` or `id` instead.
    - `values` number[], required — The query vector values. This should be the same length as the dimension of the index being queried.
    - `sparseValues` DbDataSparseValues — Vector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
      - `indices` integer[], required — The indices of the sparse data.
      - `values` number[], required — The corresponding values of the sparse data, which must be with the same length as the indices.
    - `topK` integer — An override for the number of results to return for this query vector.
    - `namespace` string — An override the namespace to search.
    - `filter` object — An override for the metadata filter to apply. This replaces the request-level filter.
  - `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`.
  - `sparseVector` DbDataSparseValues — Vector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
    - `indices` integer[], required — The indices of the sparse data.
    - `values` number[], required — The corresponding values of the sparse data, which must be with the same length as the indices.
  - `id` string — The unique ID of the vector to be used as a query vector. Each request can contain either the `vector` or `id` parameter.
  - `scanFactor` number, float — An 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.
  - `maxCandidates` integer — An 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.

## Response `200`

A successful response.

- DbDataQueryResponse — 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` DbDataSingleQueryResults[] — DEPRECATED. The results of each query. The order is the same as `QueryRequest.queries`.
    - `matches` DbDataScoredVector[] — The matches for the vectors.
      - `id` string, required — This is the vector's unique id.
      - `score` number, float — This is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.
      - `values` number[] — This is the vector data, if it is requested.
      - `sparseValues` DbDataSparseValues — Vector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
        - `indices` integer[], required — The indices of the sparse data.
        - `values` number[], required — The corresponding values of the sparse data, which must be with the same length as the indices.
      - `metadata` object — This is the metadata, if it is requested.
    - `namespace` string — The namespace for the vectors.
  - `matches` DbDataScoredVector[] — The matches for the vectors.
    - `id` string, required — This is the vector's unique id.
    - `score` number, float — This is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.
    - `values` number[] — This is the vector data, if it is requested.
    - `sparseValues` DbDataSparseValues — Vector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
      - `indices` integer[], required — The indices of the sparse data.
      - `values` number[], required — The corresponding values of the sparse data, which must be with the same length as the indices.
    - `metadata` object — This is the metadata, if it is requested.
  - `namespace` string — The namespace for the vectors.
  - `usage` DbDataUsage
    - `readUnits` integer — The number of read units consumed by this operation.

## Other responses

- `400` — Bad request. The request body included invalid request parameters.
- `4XX` — An unexpected error response.
- `5XX` — An unexpected error response.

---

[API](https://skmtc.net/pinecone/apis/pinecone-api.md) · [All operations](https://skmtc.net/pinecone/apis/pinecone-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pinecone/pinecone-api/revisions/35876583485d/schema)
