How to find nearest documents by existing indexed document id?

Let say I have thousands of articles indexed.
When a user visit one of these articles at my website, I wanna show related articles.

Right now, I’m first getting the vector from pinecone by the ID of the article that the user is visiting, then I’m querying pinecone using this vector for similar articles.

This seems like a lot of overhead though, by selecting the vector and then using it for the next query.

is there a way to query this directly using the ID of existing document?
I’m thinking something like this

index.query(
id=“123”,
top_k=3
)

Hi,

as per documentation on query: Query

Yes! You can do that with the “id” parameter.

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.

Hope this helps

1 Like

oh wow, sorry for this. I where looking at this docs Query data
The link you sent me was super helpful. thank you

1 Like