Find answers from the community

Updated 11 hours ago

I am trying to build a filter with nested OR like (A OR B) AND C but getting an error that suggests a bug in the code that translates these abstractions to Qdrant's implementation.

Hi guys! I am staring to use Qdrant as VectorStore to do some performance test, and I wanted to take advantage of the filtering capabilities using llama-index abstraction MetadataFilters. However, I faced an error which leads me to suspect there might be a bug in the piece of code that translates these abstractions to Qdrant's implementation.

I am trying to build a filter with nested OR like (A OR B) AND C. However when building this filter:
Plain Text
MetadataFilters(
            filters=[
                MetadataFilters(
                    filters=[
                        MetadataFilter(
                            key="A",
                            operator=FilterOperator.EQ,
                            value=username,
                        ),
                        MetadataFilter(
                            key="B",
                            operator=FilterOperator.EQ,
                            value=role,
                        ),
                    ],
                    condition=FilterCondition.OR,
                ),
                MetadataFilter(
                    key="C", operator=FilterOperator.NE, value=username
                ),
            ],
            condition=FilterCondition.AND,
        )
L
L
2 comments
the resulting Qdrant filter translation is this (from print):
Plain Text
should=None
min_should=None
must=[
    Filter(
        should=[
            FieldCondition(key='A', match=MatchAny(any=['username']), range=None, geo_bounding_box=None, geo_radius=None, geo_polygon=None, values_count=None),
            FieldCondition(key='B', match=MatchAny(any=['role']), range=None, geo_bounding_box=None, geo_radius=None, geo_polygon=None, values_count=None)
        ],
        min_should=None,
        must=None,
        must_not=None
    ),
    FieldCondition(key='C', match=MatchExcept(except_=['username']), range=None, geo_bounding_box=None, geo_radius=None, geo_polygon=None, values_count=None)
    ]
must_not=None

Which results in no node retrival, when there are specific nodes that match the applied filters πŸ€”
🀷 Seems right at first glance? Your filter is basically saying (A == username OR B == role) AND C != username) ?
Add a reply
Sign up and join the conversation on Discord