{"record":{"id":"053b5f265612b62c","repo":"dgraph-io/dgraph","slug":"unsupported-operation-in-facet-filtering-s","errorCode":null,"errorMessage":"Unsupported operation in facet filtering: %s.","messagePattern":"Unsupported operation in facet filtering: (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/task.go","lineNumber":2494,"sourceCode":"\t\tftree.children = append(ftree.children, ftreec)\n\t}\n\n\tnumChild := len(tree.Children)\n\tswitch ftree.op {\n\tcase \"not\":\n\t\tif numChild != 1 {\n\t\t\treturn nil, errors.Errorf(\"Expected 1 child for not but got %d.\", numChild)\n\t\t}\n\tcase \"and\":\n\t\tif numChild != 2 {\n\t\t\treturn nil, errors.Errorf(\"Expected 2 child for not but got %d.\", numChild)\n\t\t}\n\tcase \"or\":\n\t\tif numChild != 2 {\n\t\t\treturn nil, errors.Errorf(\"Expected 2 child for not but got %d.\", numChild)\n\t\t}\n\tdefault:\n\t\treturn nil, errors.Errorf(\"Unsupported operation in facet filtering: %s.\", tree.Op)\n\t}\n\treturn ftree, nil\n}\n\ntype countParams struct {\n\treadTs  uint64\n\tcounts  []int64\n\tattr    string\n\tgid     uint32\n\treverse bool   // If query is asking for ~pred\n\tfn      string // function name\n}\n\nfunc (qs *queryState) evaluate(cp countParams, out *pb.Result) error {\n\tcountl := cp.counts[0]\n\tvar counth int64\n\tif cp.fn == between {\n\t\tcounth = cp.counts[1]","sourceCodeStart":2476,"sourceCodeEnd":2512,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/task.go#L2476-L2512","documentation":"Error returned by the query processing worker (worker/task.go) when a facet filter uses an operation that is not supported for facet filtering. The unsupported operation name is reported via %s. Fix by using a supported facet filter operator.","triggerScenarios":"An internal filter tree node whose Op is neither not, and, nor or reaches the facet preprocessing — typically from a query construct unsupported in @facets or from programming errors building query trees programmatically.","commonSituations":"Using math/has/uid functions in facet position; client libraries emitting custom operator names; corrupted or hand-constructed query ASTs.","solutions":["Rewrite the facet filter using only not/and/or plus supported facet comparison functions.","If using a client library to build queries, verify it supports facets correctly for your Dgraph version.","Simplify the query to isolate which construct produces the unsupported operator."],"exampleFix":"// before\nfriend @facets(has(score))\n// after\nfriend filter has(friend) { @facets(gt(score, 3)) }","handlingStrategy":"validation","validationCode":"const allowedOps = new Set([\"not\",\"and\",\"or\"]);\nfunction validateFacetOps(tree) {\n  if (!allowedOps.has(tree.op)) throw new Error(`Unsupported facet op: ${tree.op}`);\n  (tree.children || []).forEach(validateFacetOps);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await txn.query(query);\n} catch (e) {\n  if (/Unsupported operation in facet filtering/.test(String(e))) {\n    // strip/relocate the unsupported construct and retry\n  }\n  throw e;\n}","preventionTips":["Use only not/and/or operators in facet filters.","Validate client-library query ASTs before sending.","Isolate new query constructs in tests before combining with @facets."],"tags":["dgraph","query","facets","operator"],"backgroundTag":"unsupported-facet-operator","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}