{"record":{"id":"80428233bfda2394","repo":"zincsearch/zincsearch","slug":"errortypeillegalargumentexception-804282","errorCode":"ErrorTypeIllegalArgumentException","errorMessage":"[multi_match] unknown operator %s","messagePattern":"\\[multi_match\\] unknown operator (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/uquery/query/multi_match.go","lineNumber":74,"sourceCode":"\t\t\t// return nil, errors.New(errors.ErrorTypeParsingException, fmt.Sprintf(\"[multi_match] unknown field [%s]\", k))\n\t\t}\n\t}\n\n\tvar zer *analysis.Analyzer\n\tif value.Analyzer != \"\" {\n\t\tzer, _ = zincanalysis.QueryAnalyzer(analyzers, value.Analyzer)\n\t}\n\n\tvar operator bluge.MatchQueryOperator = bluge.MatchQueryOperatorOr\n\tif value.Operator != \"\" {\n\t\top := strings.ToUpper(value.Operator)\n\t\tswitch op {\n\t\tcase \"OR\":\n\t\t\toperator = bluge.MatchQueryOperatorOr\n\t\tcase \"AND\":\n\t\t\toperator = bluge.MatchQueryOperatorAnd\n\t\tdefault:\n\t\t\treturn nil, errors.New(errors.ErrorTypeIllegalArgumentException, fmt.Sprintf(\"[multi_match] unknown operator %s\", op))\n\t\t}\n\t}\n\n\tsubq := bluge.NewBooleanQuery()\n\tif value.MinimumShouldMatch != nil {\n\t\tminValue, err := zutils.CalculateMin(len(value.Fields), value.MinimumShouldMatch)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(errors.ErrorTypeXContentParseException, fmt.Sprintf(\"[multi_match] unsupported MinimumShouldMatch value: %v\", err))\n\t\t}\n\t\tsubq.SetMinShould(minValue) // lgtm[go/hardcoded-credentials]\n\t}\n\tif value.Boost >= 0 {\n\t\tsubq.SetBoost(value.Boost)\n\t}\n\tfor _, field := range value.Fields {\n\t\tsubqq := bluge.NewMatchQuery(value.Query).SetField(field).SetOperator(operator)\n\t\tif zer != nil {\n\t\t\tsubqq.SetAnalyzer(zer)","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/zincsearch/zincsearch/blob/dd2f8afd6562d4d52c41b2c5d312280e684a25ba/pkg/uquery/query/multi_match.go#L56-L92","documentation":"MultiMatchQuery validates the operator string supplied in the multi_match query body. Only \"OR\" and \"AND\" (case-sensitive) map to bluge match operators; anything else is rejected as an illegal argument. This guards against invalid operator values being passed down to the bluge search layer.","triggerScenarios":"Calling MultiMatchQuery (via Query / ParseQueryDSL) with a multi_match body whose \"operator\" field is anything other than the exact strings \"OR\" or \"AND\" — e.g. \"or\", \"and\", \"or \" with whitespace, \"SHOULD\", or a misspelling.","commonSituations":"Copied ES DSL with lowercase operator \"or\"; dynamically built queries injecting user input into operator; typos like \"ANND\"; clients that default to Go-style naming instead of ES upper-case constants.","solutions":["Set the operator to the exact uppercase string \"OR\" or \"AND\" in the multi_match body","Trim/uppercase the operator value client-side before sending","Check the request JSON for stray whitespace or casing in the operator field","Omit the operator field entirely to use the default"],"exampleFix":"// before\n{\"multi_match\": {\"query\": \"foo\", \"fields\": [\"title\"], \"operator\": \"or\"}}\n// after\n{\"multi_match\": {\"query\": \"foo\", \"fields\": [\"title\"], \"operator\": \"OR\"}}","handlingStrategy":"validation","validationCode":"op, _ := body[\"operator\"].(string)\nif op != \"\" && op != \"OR\" && op != \"AND\" {\n    return fmt.Errorf(\"operator must be OR or AND, got %q\", op)\n}","typeGuard":"func isValidOperator(v interface{}) bool {\n    s, ok := v.(string)\n    return !ok || s == \"OR\" || s == \"AND\"\n}","tryCatchPattern":"q, err := uquery.Query(body)\nif err != nil {\n    var e *errors.Error\n    if errors.As(err, &e) && e.Type == errors.ErrorTypeIllegalArgumentException {\n        // fix operator and retry\n    }\n}","preventionTips":["Always use the uppercase literals \"OR\"/\"AND\" for operator","Normalize operator input with strings.ToUpper(strings.TrimSpace(op)) before sending","Add request-body validation at the API edge"],"tags":["query-dsl","validation","multi-match"],"backgroundTag":"invalid-query-operator","analyzedSha":"dd2f8afd6562d4d52c41b2c5d312280e684a25ba","analyzedAt":"2026-09-03T00:22:38.551Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}