Find answers from the community

Updated last month

Troubleshooting issues with vector store and document retrieval from mongo database

Hello, I'm posting again because I still have a problem with my vector store which doesn't retrieve the document from my index (stored in my mongo database), Whitefang try to help me last week on this subject but it doesn't resolved the problem. My vector store still retrieve an empty response. Here is my code, I hope somone can suggest me something else, here is my code :
W
K
28 comments
Hey! Last when we checked this, Your mongo vector store was giving 400 right? when you were trying to retrieve
Did you try updating the deps and tried again?
yess and it didn't work it still retrieve "Empty response"
Can you just show the retriever code, how are you connecting with your mongovectorstore and retriever
Plain Text
        indexName = requestDTO.Index
      
        # Initialisation des paramètres pour les requètes sur MongoDB Atlas
        mongodb_client = pymongo.MongoClient(_mongoURI)
        store = MongoDBAtlasVectorSearch(mongodb_client, db_name=indexName)

        print(store)
        
        # Initialisation de l'index via les index sur MongoDB Atlas
        # Et inversement, commenter/décommenter si on veut juste query l'index existant
        # build index
        
        index = VectorStoreIndex.from_vector_store(store)
        # configure retriever
        
        retriever = VectorIndexRetriever(
            index=index                      
        )

        # configure response synthesizer, ici on peut chosir le mode réponse pour la query(ici on peut influer sur la maniere dont le contexte et le prompt sont itéré sur la query)
        
        response_synthesizer = get_response_synthesizer(response_mode=GetResponseMode(requestDTO.Mode), text_qa_template=qa_template)

        # assemble query engine, o recupere l'index grace au retriver et aussi le mode de reponse du "ResponseMode.TREE_SUMMARIZE" via response_synthesizer 
        
        query_engine = RetrieverQueryEngine(
            retriever=retriever, 
            response_synthesizer=response_synthesizer
        )

        # Partie permettant de créer la réponse

        query_engine = index.as_query_engine(similarity_top_k=requestDTO.LinkNumber,text_qa_template=qa_template)
At the end of the code you are updating query_engine instance again. Any reason for this?

Can you try the following things and share the output:

Plain Text
- Add to your vector store 

from llama_index.core.node_parser import SentenceSplitter
from llama_index.core import Document

parser = SentenceSplitter()
nodes = parser.get_nodes_from_documents([Document(text="This is a text")])

for node in nodes:
    node_embedding = embed_model.get_text_embedding(
        node.get_content(metadata_mode="all")
    )
    node.embedding = node_embedding

store.add(nodes)


- Create retriever instance and do retrieve
index = VectorStoreIndex.from_vector_store(store)
retriever = index.as_retriever()

print(retriever.retrieve("ASK one query"))


PLease share results for these
for the code you want me to put on the side my query and put it lie this :
Attachment
image.png
Yes what's the output for these ?
the output on potsman :
retrieve code 200
@WhiteFang_Jr
This seems like you have error while adding new node in your collection in Mongo
I would suggest indexing again, something is borked in this setup for sure 🤯
i created an other index in mongodb just to test i put some document in it and now it's sayiing me that the index doesn't exist
but it exist and it's configured as it has to be configured
Could you share the code snippet for both steps
Once i’m at office i’ll share it
just to be sure you want the code for indexing don't you?
No the new code that you tried for creating index and then tried to connect again
oh i created via mongodb compass so there's no code that "create" an index
here is the vector i put in the index i created :
Attachment
image.png
it's the vector search i always use for querying
can you try creating via MongoVectorStore class from llamaindex, it could be that there is a difference in how mongo is creating the index and how llamaindex does it.
Sure let me know
i am trying to make the exemple works but does the exemple create an index in mongodb ? because i don't see any crete function, so you just want me to index other data?
Add a reply
Sign up and join the conversation on Discord