microsoft/graphrag · error · ValueError

Unsupported operator for Azure AI Search: {cond.operator}

Error message

Unsupported operator for Azure AI Search: {cond.operator}

What it means

_compile_condition translates each Operator enum member to OData/search syntax for Azure AI Search; the default case raises when the condition uses an Operator this backend never implemented. The supported set ends with exists — anything newer (or backend-inappropriate) is unsupported.

Source

Thrown at packages/graphrag-vectors/graphrag_vectors/azure_ai_search.py:251

            case Operator.lte:
                return f"{field} le {quote(value)}"
            case Operator.in_:
                items = " or ".join(f"{field} eq {quote(v)}" for v in value)
                return f"({items})"
            case Operator.not_in:
                items = " and ".join(f"{field} ne {quote(v)}" for v in value)
                return f"({items})"
            case Operator.contains:
                return f"search.ismatch('{value}', '{field}')"
            case Operator.startswith:
                return f"search.ismatch('{value}*', '{field}')"
            case Operator.endswith:
                return f"search.ismatch('*{value}', '{field}')"
            case Operator.exists:
                return f"{field} ne null" if value else f"{field} eq null"
            case _:
                msg = f"Unsupported operator for Azure AI Search: {cond.operator}"
                raise ValueError(msg)

    def _extract_data(
        self, doc: dict[str, Any], select: list[str] | None = None
    ) -> dict[str, Any]:
        """Extract additional field data from a document response."""
        fields_to_extract = select if select is not None else list(self.fields.keys())
        return {
            field_name: doc[field_name]
            for field_name in fields_to_extract
            if field_name in doc
        }

    def similarity_search_by_vector(
        self,
        query_embedding: list[float],
        k: int = 10,
        select: list[str] | None = None,
        filters: FilterExpr | None = None,

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Restrict filters for Azure AI Search to the implemented operators (eq/ne/gt/gte/lt/lte/in/startswith/endswith/exists per this version)
  2. Rewrite the filter using supported primitives (e.g. combine two conditions with And instead of an exotic operator)
  3. Check the installed graphrag-vectors changelog/source for newly supported operators and upgrade if implemented

Example fix

# before
Condition("size", Operator.between, (1, 10))
# after
And([Condition("size", Operator.gte, 1), Condition("size", Operator.lte, 10)])
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {Operator.eq, Operator.ne, Operator.gt, Operator.gte, Operator.lt, Operator.lte, Operator.in_, Operator.startswith, Operator.endswith, Operator.exists}
assert cond.operator in SUPPORTED

Type guard

def op_supported_for_azure(op: Operator) -> bool:
    return op in {Operator.eq, Operator.ne, Operator.gt, Operator.gte, Operator.lt, Operator.lte, Operator.in_, Operator.startswith, Operator.endswith, Operator.exists}

Prevention

When it happens

Trigger: Passing a Condition whose operator is defined in the shared Operator enum but not handled by the Azure AI Search compiler (any member beyond the handled cases) — e.g. an operator added for another vector backend.

Common situations: Sharing filter code between LanceDB/Cosmos and Azure AI Search backends; upgrading graphrag-vectors which adds operators not yet implemented for azure_ai_search.

Related errors


AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27). Data as JSON: /api/errors/a35214575f35186d. Report an issue: GitHub.