-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Description
I am building a system with MongoDBAtlasVectorSearch and I came across a problem which took me around 3 hours to figure out.
Specifically, when initializing MongoDBAtlasVectorSearch, the class expects your documents to contain a "text" field. After getting docs from mongodb, it filters the output based on whether the doc contains this "text" field. In my case, the field I used for storing text was called "text_clean", so I got empty retrieval outputs even though docs in my collection had embedding field and the query itself was successful. Providing a text_key optional argument to the class solves the problem.
I consider this behavior non-obvious and suggest to either explicitly include text_key argument in the examples in the docs, like
vector_store = MongoDBAtlasVectorSearch(
collection=MONGODB_COLLECTION,
embedding=embeddings,
index_name=ATLAS_VECTOR_SEARCH_INDEX_NAME,
relevance_score_fn="cosine",
text_key="the field your collection docs should contain to be included in the final retrieval output !!!!!"
)
or disable filtering of retrieval results by text_key by default.