POST
/
query
# pip install pinecone-client[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("example-index")

index.query(
    namespace="example-namespace",
    vector=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
    filter={
        "genre": {"$eq": "documentary"}
    },
    top_k=3,
    include_values=True
)
{
  "matches":[
    {
      "id": "vec3",
      "score": 0,
      "values": [0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3]
    },
    {
      "id": "vec2",
      "score": 0.0800000429,
      "values": [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
    },
    {
      "id": "vec4",
      "score": 0.0799999237,
      "values": [0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]
    }
  ],
  "namespace": "example-namespace",
  "usage": {"read_units": 6}
}
# pip install pinecone-client[grpc]
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("example-index")

index.query(
    namespace="example-namespace",
    vector=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
    filter={
        "genre": {"$eq": "documentary"}
    },
    top_k=3,
    include_values=True
)
{
  "matches":[
    {
      "id": "vec3",
      "score": 0,
      "values": [0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3]
    },
    {
      "id": "vec2",
      "score": 0.0800000429,
      "values": [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
    },
    {
      "id": "vec4",
      "score": 0.0799999237,
      "values": [0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]
    }
  ],
  "namespace": "example-namespace",
  "usage": {"read_units": 6}
}

Authorizations

Api-Key
string
headerrequired

An API Key is required to call Pinecone APIs. Get yours from the console.

Body

application/json
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 Filter with metadata.

includeValues
boolean
default: false

Indicates whether vector values are included in the response.

includeMetadata
boolean
default: false

Indicates whether metadata is included in the response as well as the ids.

queries
object[]
deprecated

DEPRECATED. The query vectors. Each query() request can contain only one of the parameters queries, vector, or id.

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
object

Vector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.

id
string

The unique ID of the vector to be used as a query vector. Each query() request can contain only one of the parameters queries, vector, or id.

Response

200 - application/json
results
object[]
deprecated

DEPRECATED. The results of each query. The order is the same as QueryRequest.queries.

matches
object[]

The matches for the vectors.

namespace
string

The namespace for the vectors.

usage
object