----------------------
To apply metadata filters in a Qdrant vector store, you can use the
MetadataFilters
and
MetadataFilter
classes from the
llama_index.core.vector_stores
module. Here is an example of how you can do it:
from llama_index.core.vector_stores import MetadataFilters, MetadataFilter, FilterOperator
# Define your filters
filters = MetadataFilters(
filters=[
MetadataFilter(key="your_key", operator=FilterOperator.EQ, value="your_value"),
# Add more filters as needed
]
)
# Use the filters when creating the retriever
retriever = index.as_retriever(filters=filters)
# Now you can retrieve with the applied filters
result = retriever.retrieve("Your query")
In the
MetadataFilter
, you specify the
key
which is the metadata field you want to filter on, the
operator
which is the comparison operator (e.g., equal, greater than, less than, etc.), and the
value
which is the value you want to compare the metadata field to.
Please replace
"your_key"
,
"your_value"
, and
"Your query"
with your actual key, value, and query.
You can find more examples in the
Qdrant Vector Store - Metadata Filter () and
Qdrant Vector Store - Default Qdrant Filters () notebooks.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------