Find answers from the community

Updated last month

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.

At a glance

A community member is using Qdrant as a VectorStore and trying to take advantage of the filtering capabilities using the llama-index abstraction MetadataFilters. However, they are facing an error that leads them to suspect a bug in the code that translates these abstractions to Qdrant's implementation. They are trying to build a filter with a nested OR like (A OR B) AND C, but the resulting Qdrant filter translation does not seem to work as expected, resulting in no node retrieval.

Another community member comments that the filter seems right at first glance, as it is basically saying (A == username OR B == role) AND C != username).

There is no explicitly marked answer.
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