Find answers from the community

Updated 2 months ago

what am i doing wrong here:

what am i doing wrong here:
index = VectorStoreIndex.from_vector_store(
vector_store=vector_store,
service_context=service_context
)

retriever = index.as_retriever(
vector_store_kwargs={"filter": {"file_name": FileName } },
similarity_top_k = 1000,
)

the filter is not applied
L
1 comment
I don't think that's the correct way to apply filters?

Plain Text
rom llama_index.vector_stores.types import (
    MetadataFilter,
    MetadataFilters,
    FilterOperator,
)

filters = MetadataFilters(
    filters=[
        MetadataFilter(
            key="theme", operator=FilterOperator.EQ, value="Fiction"
        ),
    ]
)

retriever = index.as_retriever(filters=filters)
Add a reply
Sign up and join the conversation on Discord