----------------------
Based on the information provided in the knowledge sources, it's hard to pinpoint the exact reason why your retriever is not filtering properly on the metadata. However, there are a few things you could check:
- FilterOperator: Ensure that the
FilterOperator
is set correctly. In your case, it's set to FilterOperator.EQ
which means it should return exact matches. If 'Code militaire' is not exactly the same as 'Code de justice administrative' in your data, it should not be returned.
- Metadata Key-Value Pair: Make sure that the key-value pair in your filter matches exactly with the metadata in your data. In your case, the key is 'file_root' and the value is 'Code militaire'. If there's any discrepancy in the key or value, the filter might not work as expected.
- Data Consistency: Check if your data is consistent. If there are any inconsistencies or errors in your data, it might affect the filtering process.
- Filter Application: Ensure that the filters are being applied correctly when creating the retriever. The filters should be passed as an argument to the
as_retriever
method of the index.
Here's an example of how to create a retriever with filters:
from llama_index.core.vector_stores import MetadataFilter, MetadataFilters, FilterOperator
filters = MetadataFilters(
filters=[
MetadataFilter(key="file_root", operator=FilterOperator.EQ, value="Code militaire"),
]
)
retriever = index.as_retriever(filters=filters)
If you've checked all these points and the issue still persists, it might be a good idea to look into the documentation of LlamaIndex or reach out to the community for help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------