{"record":{"id":"eb712f97570f2a6e","repo":"run-llama/llama_index","slug":"extra-filters-cannot-be-or-condition","errorCode":null,"errorMessage":"extra_filters cannot be OR condition","messagePattern":"extra_filters cannot be OR condition","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/vector_store/retrievers/auto_retriever/auto_retriever.py","lineNumber":108,"sourceCode":"        self._default_empty_query_vector = default_empty_query_vector\n        self._llm = llm or Settings.llm\n        callback_manager = callback_manager or Settings.callback_manager\n\n        # prompt\n        prompt_template_str = (\n            prompt_template_str or DEFAULT_VECTOR_STORE_QUERY_PROMPT_TMPL\n        )\n        self._output_parser = VectorStoreQueryOutputParser()\n        self._prompt: BasePromptTemplate = PromptTemplate(template=prompt_template_str)\n\n        # additional config\n        self._max_top_k = max_top_k\n        self._similarity_top_k = similarity_top_k\n        self._empty_query_top_k = empty_query_top_k\n        self._vector_store_query_mode = vector_store_query_mode\n        # if extra_filters is OR condition, we don't support that yet\n        if extra_filters is not None and extra_filters.condition == FilterCondition.OR:\n            raise ValueError(\"extra_filters cannot be OR condition\")\n        self._extra_filters = extra_filters or MetadataFilters(filters=[])\n        self._kwargs = kwargs\n        super().__init__(\n            callback_manager=callback_manager,\n            object_map=object_map or self._index._object_map,\n            objects=objects,\n            verbose=verbose,\n        )\n\n    def _get_prompts(self) -> PromptDictType:\n        \"\"\"Get prompts.\"\"\"\n        return {\n            \"prompt\": self._prompt,\n        }\n\n    def _update_prompts(self, prompts: PromptDictType) -> None:\n        \"\"\"Get prompt modules.\"\"\"\n        if \"prompt\" in prompts:","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/vector_store/retrievers/auto_retriever/auto_retriever.py#L90-L126","documentation":"VectorIndexAutoRetriever.__init__ raises ValueError('extra_filters cannot be OR condition') when extra_filters is provided with extra_filters.condition == FilterCondition.OR. The auto-retriever already synthesizes its own metadata filters from the LLM; combining LLM-generated filters with OR-joined extra filters via the query-spec path is not implemented, so only AND conditions are accepted (the extra filters then narrow the LLM's selection).","triggerScenarios":"VectorIndexAutoRetriever(index, extra_filters=MetadataFilters(filters=[...], condition=FilterCondition.OR)); note MetadataFilters' default condition is 'and', so this only fires when OR is set explicitly.","commonSituations":"Trying to scope retrieval to 'tenant_id == A OR tenant_id == B'; multi-tenant or environment-scoping filters written with OR; migrating hand-built MetadataFilters(OR) queries into the auto-retriever.","solutions":["Use FilterCondition.AND (or omit condition) for extra_filters.","If you truly need OR logic across extra filters, precompute a single filter value (e.g. one 'tenant_ids' field with an IN operator filter) or filter results after retrieval.","For full OR control, use a plain VectorIndexRetriever with your own MetadataFilters instead of the auto-retriever."],"exampleFix":"# before\nfilters = MetadataFilters(\n    filters=[MetadataFilter(key=\"tenant\", value=\"a\"), MetadataFilter(key=\"tenant\", value=\"b\")],\n    condition=FilterCondition.OR,\n)\nretriever = VectorIndexAutoRetriever(index, extra_filters=filters)  # ValueError\n\n# after\nfilters = MetadataFilters(filters=[MetadataFilter(key=\"env\", value=\"prod\")])  # AND (default)\nretriever = VectorIndexAutoRetriever(index, extra_filters=filters)","handlingStrategy":"validation","validationCode":"from llama_index.core.vector_stores.types import FilterCondition, MetadataFilters\n\ndef extra_filters_are_compatible(filters: MetadataFilters) -> bool:\n    return filters is None or filters.condition != FilterCondition.OR","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass AND-composed (default-condition) MetadataFilters as extra_filters to VectorIndexAutoRetriever.","Model multi-value scoping as a single field with an IN/ANY operator filter instead of OR'd filters.","Need full OR semantics? Use VectorIndexRetriever with hand-built MetadataFilters."],"tags":["vector-store","metadata-filters","auto-retriever","llama-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}