OrchardCMS/OrchardCore · error · ArgumentException

Invalid property ' ' in boolean query

Error message

Invalid property '{property.Key}' in boolean query

What it means

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.

Solutions

  1. Remove or rename the invalid property to one of: must, mustNot, should, minimum_should_match, filter.
  2. Check for typos (e.g. 'must_not' should be 'mustNot').
  3. Validate the boolean fragment keys against the provider's supported list before execution.

Example fix

// before
{"query":{"bool":{"must_not":[{"term":{"x":"y"}}]}}}
// after
{"query":{"bool":{"mustNot":[{"term":{"x":"y"}}]}}}
Defensive patterns

Strategy: validation

Validate before calling

var allowed = new[] { "must", "mustNot", "should", "minimum_should_match", "filter" };
foreach (var prop in boolObj)
    if (!allowed.Contains(prop.Key))
        throw new ArgumentException($"Unsupported boolean property: {prop.Key}");

Type guard

static bool IsValidBoolProperty(string key) => key is "must" or "mustNot" or "should" or "minimum_should_match" or "filter";

Try / catch

try { var docs = await searchAsync(query); }
catch (ArgumentException ex) when (ex.Message.Contains("Invalid property")) { log.LogError(ex); return BadRequest(ex.Message); }

Prevention

When it happens

Trigger: A boolean query fragment like {"bool":{"must":[...],"shoud":[...]}} containing a typo or unsupported key.

Common situations: Typos in query JSON, copy-pasted DSL from Elasticsearch that uses unsupported properties, or camelCase/snake_case mix-ups.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/08873e823afeeb60. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/BooleanQueryProvider.cs:53

                    break;
                case "mustnot":
                case "must_not":
                    occur = Occur.MUST_NOT;
                    break;
                case "should":
                    occur = Occur.SHOULD;
                    break;
                case "boost":
                    boolQuery.Boost = property.Value.Value<float>();
                    isProps = true;
                    break;
                case "minimum_should_match":
                    boolQuery.MinimumNumberShouldMatch = property.Value.Value<int>();
                    isProps = true;
                    break;
                case "filter":
                    return CreateFilteredQuery(builder, context, boolQuery, property.Value);
                default: throw new ArgumentException($"Invalid property '{property.Key}' in boolean query");
            }

            if (!isProps)
            {
                switch (property.Value.GetValueKind())
                {
                    case JsonValueKind.Object:
                        boolQuery.Add(builder.CreateQueryFragment(context, property.Value.AsObject()), occur);
                        break;
                    case JsonValueKind.Array:
                        foreach (var item in property.Value.AsArray())
                        {
                            if (item.GetValueKind() != JsonValueKind.Object)
                            {
                                throw new ArgumentException($"Invalid value in boolean query");
                            }
                            boolQuery.Add(builder.CreateQueryFragment(context, item.AsObject()), occur);
                        }

View on GitHub (pinned to 4306c0717f)