Find answers from the community

Updated 9 months ago

do you have any example ? πŸ˜„

do you have any example ? πŸ˜„
T
A
7 comments
You can add metadata first:

Plain Text
document = Document(
    text="text",
    metadata={"filename": "<doc_file_name>", "category": "<category>"},
)

https://docs.llamaindex.ai/en/stable/understanding/loading/loading.html#adding-metadata

Then you can build filters:

Plain Text
filters = MetadataFilters(
    filters=[
        MetadataFilter(key="product_category", operator=FilterOperator.EQ, value="shoes")
    ]
)

You can pass those in the query:

Plain Text
retriever = index.as_retriever(filters=filters)
when I use something like this it works fine :

Plain Text
        filters = MetadataFilters(
            filters=[
                MetadataFilter(key="file_name", operator=FilterOperator.EQ, value="file1.txt"),
            ],
        )


However when using something like this to add multiple files:


Plain Text
        filters = MetadataFilters(
            filters=[
                MetadataFilter(key="file_name", operator=FilterOperator.IN, value=["file1.txt", "file2.txt"]),
            ],
        )


I've this error : ValueError: Vector Store only supports exact match filters. Please use ExactMatchFilter or FilterOperator.EQ instead
Which vector store are you using? I know some of them have limitations with filtering
I use VectorStoreIndex
which one should I use?
Are you using a 3rd party service for storing it?
Add a reply
Sign up and join the conversation on Discord