Why getting error No query provided in /query

Why I am getting this error on /query api
{
“includeValues”: true,
“topK”: 10,
“namespace”: “development”,
“filters”: {
“itemId”: {
“$eq”: 1
}
}

}

curl

curl --location --request POST 'https://index_name-project_id.svc.environment.pinecone.io/query' \
--header 'Api-Key: test-123' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data-raw '{
    "includeValues": true,
    "topK": 10,
    "namespace": "development",
        "filters": {
            "itemId": {
                "$eq": 1
            }
        }
    
}'

Hi @parmod. It’s because you’re not supplying any vectors in the query. Pinecone queries must have a vector to compute against; they can’t be run against metadata only. The metadata is there to filter out vectors that don’t match it, but the query still has to have the embeddings you’re comparing.

Thank you got it. Is there any way we can query without vectors

1 Like

I’m also wondering this

Hello!

Currently, there is no way to execute queries without using vectors in Pinecone. However, you can use the Fetch API to retrieve vectors based on IDs alone. You can find more information about using the Fetch API in the Pinecone documentation.

Could you provide specific scenarios where you need to query without using vectors? If vector search is not required, it might be more appropriate to manage your data using databases like SQL Server or MongoDB.

Hi,

Yes, I can provide an example where it is not convenient to perform a query using vectors.

Suppose I am fetching docs from MongoDB to generate embeddings. Also, assume that I have some preprocessing to do on those docs using a paid AI API before I can perform the embeddings.

It seems quite obvious to me that it would be recommended to check my Pinecone index to see if the embedded docs have already been stored there, right?

Now, how am I supposed to look up my Pinecone index if in order to do so I would have to generate embeddings for each and every one document in my MongoDB collection, even for those that have already been previously upserted into my Pinecone index. It does not make any sense, at least to me.

What I would like to have is the possibility to look up at my Pinecone index without being constrained to provide a vector to query against. Here, a metadata query would come in very handy.

Regs,

Rafael

I think this is a crucial feature to have, for many reasons. Not just de-duplication but also the deletion of existing vectors. There must be a way to retrieve all vectors with certain metadata in order to manage them.

Any update on this? Would be easier to manage the processing pipeline if we can search using metadata only. Right now, we need another database to track the documents that have been already been indexed.

@parmod
You can query without a vector - its just not as intuitive as you would think.

Simply supply an n-dimension vector that is all zeros.
So whatever the dimension of your Pinecone index is, supply an array of all zeros in addition to your query as it is written above and if will return a result that matches just the metadata values.

# If pinecone index dimensions are 1536 (openai text-ada-embedding-002)

# rest of code
--data-raw '{
    "vector": [0,0,0,0.....0], #this is 1536 items long.
    "includeValues": true,
    "topK": 10,
    "namespace": "development",
        "filters": {
            "itemId": {
                "$eq": 1
            }
        }
}'

# output => up to 10 results that match ItemId === 1 in development namespace.

Be wary, there is an upper limit for topK if returning values. I believe it is around 1,000 which can break this script if the metadata query results are more generic.