{"record":{"id":"08873e823afeeb60","repo":"OrchardCMS/OrchardCore","slug":"invalid-property-property-key-in-boolean-query","errorCode":null,"errorMessage":"Invalid property '{property.Key}' in boolean query","messagePattern":"Invalid property '(.+?)' in boolean query","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/BooleanQueryProvider.cs","lineNumber":53,"sourceCode":"                    break;\n                case \"mustnot\":\n                case \"must_not\":\n                    occur = Occur.MUST_NOT;\n                    break;\n                case \"should\":\n                    occur = Occur.SHOULD;\n                    break;\n                case \"boost\":\n                    boolQuery.Boost = property.Value.Value<float>();\n                    isProps = true;\n                    break;\n                case \"minimum_should_match\":\n                    boolQuery.MinimumNumberShouldMatch = property.Value.Value<int>();\n                    isProps = true;\n                    break;\n                case \"filter\":\n                    return CreateFilteredQuery(builder, context, boolQuery, property.Value);\n                default: throw new ArgumentException($\"Invalid property '{property.Key}' in boolean query\");\n            }\n\n            if (!isProps)\n            {\n                switch (property.Value.GetValueKind())\n                {\n                    case JsonValueKind.Object:\n                        boolQuery.Add(builder.CreateQueryFragment(context, property.Value.AsObject()), occur);\n                        break;\n                    case JsonValueKind.Array:\n                        foreach (var item in property.Value.AsArray())\n                        {\n                            if (item.GetValueKind() != JsonValueKind.Object)\n                            {\n                                throw new ArgumentException($\"Invalid value in boolean query\");\n                            }\n                            boolQuery.Add(builder.CreateQueryFragment(context, item.AsObject()), occur);\n                        }","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/BooleanQueryProvider.cs#L35-L71","documentation":"The Lucene boolean query provider only recognizes the properties must, mustNot, should, minimum_should_match, and filter inside a boolean query object. Any other property name throws ArgumentException naming the offending key.","triggerScenarios":"A boolean query fragment like {\"bool\":{\"must\":[...],\"shoud\":[...]}} containing a typo or unsupported key.","commonSituations":"Typos in query JSON, copy-pasted DSL from Elasticsearch that uses unsupported properties, or camelCase/snake_case mix-ups.","solutions":["Remove or rename the invalid property to one of: must, mustNot, should, minimum_should_match, filter.","Check for typos (e.g. 'must_not' should be 'mustNot').","Validate the boolean fragment keys against the provider's supported list before execution."],"exampleFix":"// before\n{\"query\":{\"bool\":{\"must_not\":[{\"term\":{\"x\":\"y\"}}]}}}\n// after\n{\"query\":{\"bool\":{\"mustNot\":[{\"term\":{\"x\":\"y\"}}]}}}","handlingStrategy":"validation","validationCode":"var allowed = new[] { \"must\", \"mustNot\", \"should\", \"minimum_should_match\", \"filter\" };\nforeach (var prop in boolObj)\n    if (!allowed.Contains(prop.Key))\n        throw new ArgumentException($\"Unsupported boolean property: {prop.Key}\");","typeGuard":"static bool IsValidBoolProperty(string key) => key is \"must\" or \"mustNot\" or \"should\" or \"minimum_should_match\" or \"filter\";","tryCatchPattern":"try { var docs = await searchAsync(query); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Invalid property\")) { log.LogError(ex); return BadRequest(ex.Message); }","preventionTips":["Remember property names are camelCase: mustNot, minimum_should_match.","Do not paste Elasticsearch boolean DSL verbatim; check key support first."],"tags":["lucene","query-dsl","boolean-query"],"backgroundTag":"invalid-argument-value","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}