{"record":{"id":"ea9ca9d02a9664a6","repo":"microsoft/semantic-kernel","slug":"only-and-of-comparisons-is-supported","errorCode":null,"errorMessage":"Only 'and' of == comparisons is supported.","messagePattern":"Only 'and' of == comparisons is supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/_search_shared.py","lineNumber":48,"sourceCode":"            raise NotImplementedError(\"Left side must be x.FIELD.\")\n        field = node.left.attr\n        if not (len(node.ops) == 1 and isinstance(node.ops[0], ast.Eq)):\n            raise NotImplementedError(\"Only == comparisons are supported.\")\n        right = node.comparators[0]\n        if isinstance(right, ast.Constant):\n            if right.value is None:\n                raise NotImplementedError(\"None values are not supported.\")\n            value = str(right.value)\n        else:\n            raise NotImplementedError(\"Only constant values are supported on the right side.\")\n        if field not in self.valid_parameters:\n            raise ValueError(f\"Field '{field}' is not supported.\")\n        self.filters.append({field: quote_plus(value)})\n\n    @override\n    def visit_BoolOp(self, node):\n        if not isinstance(node.op, ast.And):\n            raise NotImplementedError(\"Only 'and' of == comparisons is supported.\")\n        for v in node.values:\n            self.visit(v)\n","sourceCodeStart":30,"sourceCodeEnd":51,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/_search_shared.py#L30-L51","documentation":"When combining multiple comparisons the visitor (visit_BoolOp) only accepts ast.And. A BoolOp whose op is not `and` (e.g. `or`, or `not`-style logic) raises NotImplementedError before visiting children.","triggerScenarios":"Using `or` between clauses: `lambda x: x.a == 1 or x.b == 2`, or any non-and boolean combination.","commonSituations":"Wanting OR semantics for multi-value filters; assuming full boolean expression support.","solutions":["Combine clauses only with `and` (`lambda x: x.a == 1 and x.b == 2`).","OR-style multi-value matching is not supported by this filter DSL; narrow to a single value or run multiple queries and merge client-side."],"exampleFix":"// before\nlambda x: x.country == \"us\" or x.country == \"ca\"\n\n// after\nlambda x: x.country == \"us\"  # pick one; 'or' is unsupported by the visitor","handlingStrategy":"validation","validationCode":"import ast\nnode = ast.parse(filter_src, mode='eval').body\ndef check_and(n):\n    if isinstance(n, ast.BoolOp):\n        assert isinstance(n.op, ast.And), \"only 'and' supported\"\n        for v in n.values: check_and(v)\ncheck_and(node.body)","typeGuard":"def boolop_is_and(node: ast.BoolOp) -> bool:\n    return isinstance(node.op, ast.And)","tryCatchPattern":null,"preventionTips":["Combine filter clauses only with 'and'","Avoid 'or'/negation which the DSL does not support","Run multiple queries and merge client-side for OR semantics"],"tags":["search","filters","lambda","ast"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}