Skip to content

filter by equal not working with Qdrant #387

@samsja

Description

@samsja

The issue

Pre-filtering with the operator equal is not working with qdrant backend.

For instance using the filter {'must': [{'key': 'price', 'value': {'eq': 7}}]} will not match any docs even though one has the price 7. See the following code snippet to reproduce it.

from docarray import Document, DocumentArray
import numpy as np

n_dim = 3
distance = 'euclidean'

da = DocumentArray(
    storage='qdrant',
    config={'n_dim': n_dim, 'columns': [('price', 'int')], 'distance': distance},
)

with da:
    da.extend(
        [
            Document(id=f'r{i}', embedding=i * np.ones(n_dim), tags={'price': i})
            for i in range(10)
        ]
    )

max_price = 7
n_limit = 4

np_query = np.ones(n_dim) * 8

filter = {'must': [{'key': 'price', 'value': {'eq': 7}}]}
results = da.find(np_query, filter=filter, limit=n_limit)

print(len(results))
>>> 0

The tests passed but are actually failing. Indeed the assert here passed only because the results are empty therefore doing assert all([]) passed.

CC: @davidbp

Possible solution:

Maybe the filter is not written properly

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions