llama_index icon indicating copy to clipboard operation
llama_index copied to clipboard

[Feature Request]: multiple value filter on same key in mongoDB vector store.

Open JuHyung-Son opened this issue 1 year ago • 0 comments

Feature Description

MongoDB vectore store does not support mutiple value filter on same key. However, this seems to be a very important feature.

llama_index.vector_stores.mongodb.base.py

def _to_mongodb_filter(standard_filters: MetadataFilters) -> Dict:
    """Convert from standard dataclass to filter dict."""
    filters = {}
    for filter in standard_filters.legacy_filters():
        filters[filter.key] = filter.value  # <- here, this does not make multiple values on key not applied
    return filters

I want to use filters like below.

filters = MetadataFilters(
    filters=[
        ExactMatchFilter(key="metadata.team", value="TEAM1"),   
        ExactMatchFilter(key="metadata.team", value="TEAM2"), # <- multiple values on key "metadata.team"
    ],
    condition=FilterCondition.OR,
)
 # MongoDBAtlasVectorSearch
query_engine = index.as_query_engine(
    filters=filters,
)

I don't know if this is caused by the llama index vector store not supporting the In operator, but I'd like you to look into it.

JuHyung-Son avatar May 05 '24 02:05 JuHyung-Son