Reputation: 832
I'm using Qdrant database through its Python client. I need to find entries in the database that have some metadata field set to a certain value (without using vector similarity). I'm trying to do it this way:
from qdrant_client.http import models
condition = models.FieldCondition(key="field_name", match=models.MatchValue(value="some_value"))
scroll_filter = models.Filter(must=[condition])
results = client.scroll(collection_name="my_collection", scroll_filter=scroll_filter)
I know that there are points that have metadata "field_name=some_value", but the response is ([], None)
no matter what I try. Is there a way to query the database based on metadata only?
(Note: client.scroll(collection_name="my_collection")
indeed returns results, some of them having the required key/value pair in the metadata. It's the filter that doesn't seem to work.)
EDIT: The problem was that the data was originally inserted using LangChain, which puts the metadata object within the payload. That further means that instead of using condition=FieldCondition(key="field_name", ...
, one must use condition=FieldCondition(key="metadata.field_name", ...
.
Upvotes: 3
Views: 1984
Reputation: 51
Nothing seems to be wrong at the first glance. Would you be able to share the output of the client.scroll(collection_name="my_collection")
with at least one point matching the criteria? I'd like to verify the structure of the payload.
Upvotes: 0