Thank you, however i'm confused on why what i'm doing doesn't work:
I'm trying to filter vector search results by metadata in Qdrant using LlamaIndex, but nothing seems to work. Here's what I've tried:
- Using MetadataFilters with ExactMatchFilter:
filters = MetadataFilters(filters=[
ExactMatchFilter(key="space_id", value=space_access.space_id)
])
- Using MetadataFilters with MetadataFilter and FilterOperator:
filters = MetadataFilters(filters=[
MetadataFilter(key="space_id", operator=FilterOperator.EQ, value=space_access.space_id)
])
- Using direct Qdrant payload filters:
filter_condition = {
"must": [
{
"key": "space_id",
"match": {"value": space_access.space_id}
}
]
}
None of these work - I keep getting results from multiple different space_ids (2, 6, 7, 8) instead of just the one I want.
Looking at my data in Qdrant (from the response), I can see the metadata is structured like this:
"metadata": {
"id": 14,
"name": "report.pdf",
"space_id": 6, # This is what I want to filter by
...
}
What's the correct way to filter by a nested metadata field in Qdrant using the latest LlamaIndex version? Can you show me a complete example that actually works with nested metadata fields?