Skip to content

MongoDBAtlasVectorSearch ambiguous behavior #211

@evgeniishch

Description

@evgeniishch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions