OrchardCMS/OrchardCore · error · ArgumentException

Missing value in fuzzy query

Error message

Missing value in fuzzy query

What it means

The fuzzy filter provider requires the fuzzy query object to contain a 'value' property specifying the text to fuzzily match. When the object (or its 'value' key) is missing, it throws ArgumentException.

Solutions

  1. Add a 'value' property to the fuzzy object: {"fuzzy":{"field":{"value":"text"}}}.
  2. Do not use the ES shorthand string form; always use the object form.
  3. Check that the fuzzy filter JSON contains 'value' before execution.

Example fix

// before
{"fuzzy":{"title":{"fuzziness":2}}}
// after
{"fuzzy":{"title":{"value":"orchard","fuzziness":2}}}
Defensive patterns

Strategy: validation

Validate before calling

if (fuzzyNode is not JsonObject o || o["value"] is null)
    throw new ArgumentException("Fuzzy filter requires a 'value' property.");

Type guard

static bool HasFuzzyValue(JsonNode? n) => n is JsonObject o && o["value"] is not null;

Try / catch

try { var q = fuzzyProvider.CreateFilteredQuery(builder, ctx, filterName, node); }
catch (ArgumentException ex) when (ex.Message == "Missing value in fuzzy query") { /* surface DSL error */ }

Prevention

When it happens

Trigger: A filter like {"fuzzy":{"field":{}}} or {"fuzzy":{"field":{"fuzziness":2}}} without 'value'.

Common situations: Shorthand Elasticsearch syntax {"fuzzy":{"field":"text"}} being expected but the provider only accepting the object form with an explicit 'value'.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/FuzzyFilterProvider.cs:38

            return null;
        }

        var queryObj = filter.AsObject();
        var first = queryObj.First();

        FuzzyQuery fuzzyQuery;

        switch (first.Value.GetValueKind())
        {
            case JsonValueKind.String:
                fuzzyQuery = new FuzzyQuery(new Term(first.Key, first.Value.ToString()));
                break;
            case JsonValueKind.Object:
                var obj = first.Value.AsObject();

                if (!obj.TryGetPropertyValue("value", out var value))
                {
                    throw new ArgumentException("Missing value in fuzzy query");
                }

                obj.TryGetPropertyValue("fuzziness", out var fuzziness);
                obj.TryGetPropertyValue("prefix_length", out var prefixLength);
                obj.TryGetPropertyValue("max_expansions", out var maxExpansions);

                fuzzyQuery = new FuzzyQuery(
                    new Term(first.Key, value.Value<string>()),
                    fuzziness?.Value<int>() ?? LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE,
                    prefixLength?.Value<int>() ?? 0,
                    maxExpansions?.Value<int>() ?? 50,
                    true);

                if (obj.TryGetPropertyValue("boost", out var boost))
                {
                    fuzzyQuery.Boost = boost.Value<float>();
                }

View on GitHub (pinned to 4306c0717f)