How to create embeddings and retrieval queries for MongoDB documents with a nested structure using LangChain?

Hello forum members,

I hope this message finds you well. I’m currently working on a project that involves store embeddings of JSON and retrieval in MongoDB using langchain, and I’m seeking insights and best practices from the community.

And also I have tried the tutorials by mongo DB but its only works on that particular example like loading documents using loaders.

Question:

  1. How to store the embeddings of JSON which is already in the collection (as Nested JSON)?
    2.How to create search index for it?
    3.How to retrieve that nested JSON data’s based on user input?

If you have hands-on experience or insights into any of these aspects, please share your thoughts. Your expertise will be immensely valuable to me and others navigating similar challenges.

Thank you in advance for your contributions to the discussion!

Hello @Vishnu_Priyan

For your first question, the only way to store embeddings for documents that are already in your collection is to go through and update each one by adding a field that holds the new Vector Embedding. (The embedding would be created by sending the relevant data to an embedding model to create the embedding).

Creating a vector search index can be done through the UI or API - instructions are here

To retrieve results, you must take the users input and create a vector with it, then you will pass that vector to the $vectorSearch stage documented here.

2 Likes

Hello @Benjamin_Flast,
Thank you for your response to my question. Your input was very helpful.

1 Like

I have find alternative way to solve this problem.
Kindly refer this langchain QA link