Yea that's why I mentioned if you knew the filter ahead of time π
If you know the filtering ahead of time, you can apply it like this example
from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters
filters = MetadataFilters(filters=[ExactMatchFilter(key="theme", value="Mafia")])
query_engine = index.as_query_engine(filters=filters)
If you dont know the filters ahead of time, you need some process for getting that. You could use the auto query engine which gets the LLM to try and configure filters for you (example is for pinecone. but it will work with chroma too)
https://gpt-index.readthedocs.io/en/stable/examples/vector_stores/chroma_auto_retriever.html#define-vectorindexautoretrieverOr you could run an initial processing step with a pydantic program to try and infer filters before querying
https://gpt-index.readthedocs.io/en/stable/examples/output_parsing/openai_pydantic_program.html