Skip to content

How return id from ConvexVectorStore.fromDocuments #6350

Answered by dosubot bot
teomikitenko asked this question in Q&A
Discussion options

You must be logged in to vote

To determine the ID provided by the database for the embedding created using ConvexVectorStore.fromDocuments, you can use the addDocuments method and provide your own IDs. If you do not provide IDs, the system will generate UUIDs for you. Here is an example of how you can retrieve the IDs:

await withVectorStore(async (vectorStore: MomentoVectorIndex) => {
  const pageContent = faker.lorem.sentence(5);

  // Add documents without providing IDs, so UUIDs will be generated
  await vectorStore.addDocuments([{ pageContent, metadata: {} }]);
  await sleep();
  
  // Perform a similarity search to retrieve the document
  const results = await vectorStore.similaritySearch(pageContent, 1);
  
  /…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by teomikitenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant