{"record":{"id":"7ddc1ae92e664db4","repo":"deepset-ai/haystack","slug":"unknown-comparison-operator-operator-valid-op","errorCode":null,"errorMessage":"Unknown comparison operator '{operator}'. Valid operators are: {sorted(COMPARISON_OPERATORS)}","messagePattern":"Unknown comparison operator '(.+?)'\\. Valid operators are: (.+?)","errorType":"exception","errorClass":"FilterError","httpStatus":null,"severity":"error","filePath":"haystack/utils/filters.py","lineNumber":329,"sourceCode":"                # If a field is not found (or an intermediate value is not a dict,\n                # e.g. None) we treat it as None\n                document_value = None\n                break\n            document_value = document_value[part]\n    elif field not in [f.name for f in fields(document)]:\n        # Converted legacy filters don't add the `meta.` prefix, so we assume\n        # that all filter fields that are not actual fields in Document are converted\n        # filters.\n        #\n        # We handle this to avoid breaking compatibility with converted legacy filters.\n        # This will be removed as soon as we stop supporting legacy filters.\n        document_value = document.meta.get(field)\n    else:\n        document_value = getattr(document, field)\n    operator: str = condition[\"operator\"]\n    if operator not in COMPARISON_OPERATORS:\n        msg = f\"Unknown comparison operator '{operator}'. Valid operators are: {sorted(COMPARISON_OPERATORS)}\"\n        raise FilterError(msg)\n    filter_value: Any = condition[\"value\"]\n    return COMPARISON_OPERATORS[operator](\n        filter_value=filter_value, value=document_value, strict_datetime_comparison=strict_datetime_comparison\n    )\n","sourceCodeStart":311,"sourceCodeEnd":334,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/utils/filters.py#L311-L334","documentation":"FilterError raised by `_comparison_condition` when the condition's 'operator' string is not one of the registered COMPARISON_OPERATORS (e.g. ==, !=, >, >=, <, <=, in, not in). The operator lookup dict is only populated with supported comparison functions, so an unknown string cannot be dispatched.","triggerScenarios":"Passing a condition like {'field': 'meta.price', 'operator': 'equals', 'value': 10} or '==' misspellings / unsupported operators such as '~=', 'contains' (if not registered), 'like', or 'gt' to document_matches_filter, _and, _or, or any component that applies filters.","commonSituations":"Typo in the operator string; using natural-language operator names instead of the symbols Haystack expects; copying filter syntax from another library (e.g. Elasticsearch 'term'/'match' or pandas style); code that predates an operator being added.","solutions":["Use a valid operator from COMPARISON_OPERATORS (==, !=, >, >=, <, <=, in, not in as registered)","Print haystack.utils.filters.COMPARISON_OPERATORS.keys() to see exactly which operators your version supports","Check for typos and case-sensitivity in the operator string"],"exampleFix":"// before\nfilters = {\"field\": \"meta.price\", \"operator\": \"gt\", \"value\": 10}\n// after\nfilters = {\"field\": \"meta.price\", \"operator\": \">\", \"value\": 10}","handlingStrategy":"validation","validationCode":"from haystack.utils.filters import COMPARISON_OPERATORS\ndef validate_operator(cond):\n    if cond.get(\"operator\") not in COMPARISON_OPERATORS:\n        raise ValueError(f\"operator must be one of {sorted(COMPARISON_OPERATORS)}\")","typeGuard":"def has_known_operator(c) -> bool:\n    from haystack.utils.filters import COMPARISON_OPERATORS\n    return isinstance(c, dict) and c.get(\"operator\") in COMPARISON_OPERATORS","tryCatchPattern":"from haystack.utils import FilterError\ntry:\n    result = document_matches_filter(doc, condition)\nexcept FilterError as e:\n    raise ValueError(f\"Unsupported filter: {e}\") from e","preventionTips":["Use the symbolic operators Haystack registers (==, !=, >, >=, <, <=, in, not in)","Check COMPARISON_OPERATORS.keys() for your installed version before using an operator","Avoid copying operator syntax from other systems (SQL, Elasticsearch)"],"tags":["haystack","filters","filtererror","invalid-operator"],"backgroundTag":"invalid-enum-value","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}