{"record":{"id":"d6d6e3d2c87f0cf8","repo":"OrchardCMS/OrchardCore","slug":"missing-value-in-fuzzy-query","errorCode":null,"errorMessage":"Missing value in fuzzy query","messagePattern":"Missing value in fuzzy query","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/FuzzyFilterProvider.cs","lineNumber":38,"sourceCode":"            return null;\n        }\n\n        var queryObj = filter.AsObject();\n        var first = queryObj.First();\n\n        FuzzyQuery fuzzyQuery;\n\n        switch (first.Value.GetValueKind())\n        {\n            case JsonValueKind.String:\n                fuzzyQuery = new FuzzyQuery(new Term(first.Key, first.Value.ToString()));\n                break;\n            case JsonValueKind.Object:\n                var obj = first.Value.AsObject();\n\n                if (!obj.TryGetPropertyValue(\"value\", out var value))\n                {\n                    throw new ArgumentException(\"Missing value in fuzzy query\");\n                }\n\n                obj.TryGetPropertyValue(\"fuzziness\", out var fuzziness);\n                obj.TryGetPropertyValue(\"prefix_length\", out var prefixLength);\n                obj.TryGetPropertyValue(\"max_expansions\", out var maxExpansions);\n\n                fuzzyQuery = new FuzzyQuery(\n                    new Term(first.Key, value.Value<string>()),\n                    fuzziness?.Value<int>() ?? LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE,\n                    prefixLength?.Value<int>() ?? 0,\n                    maxExpansions?.Value<int>() ?? 50,\n                    true);\n\n                if (obj.TryGetPropertyValue(\"boost\", out var boost))\n                {\n                    fuzzyQuery.Boost = boost.Value<float>();\n                }\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/FuzzyFilterProvider.cs#L20-L56","documentation":"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.","triggerScenarios":"A filter like {\"fuzzy\":{\"field\":{}}} or {\"fuzzy\":{\"field\":{\"fuzziness\":2}}} without 'value'.","commonSituations":"Shorthand Elasticsearch syntax {\"fuzzy\":{\"field\":\"text\"}} being expected but the provider only accepting the object form with an explicit 'value'.","solutions":["Add a 'value' property to the fuzzy object: {\"fuzzy\":{\"field\":{\"value\":\"text\"}}}.","Do not use the ES shorthand string form; always use the object form.","Check that the fuzzy filter JSON contains 'value' before execution."],"exampleFix":"// before\n{\"fuzzy\":{\"title\":{\"fuzziness\":2}}}\n// after\n{\"fuzzy\":{\"title\":{\"value\":\"orchard\",\"fuzziness\":2}}}","handlingStrategy":"validation","validationCode":"if (fuzzyNode is not JsonObject o || o[\"value\"] is null)\n    throw new ArgumentException(\"Fuzzy filter requires a 'value' property.\");","typeGuard":"static bool HasFuzzyValue(JsonNode? n) => n is JsonObject o && o[\"value\"] is not null;","tryCatchPattern":"try { var q = fuzzyProvider.CreateFilteredQuery(builder, ctx, filterName, node); }\ncatch (ArgumentException ex) when (ex.Message == \"Missing value in fuzzy query\") { /* surface DSL error */ }","preventionTips":["Always spell out {\"value\":\"...\"} in fuzzy filters; no ES shorthand.","Validate fuzzy nodes in a query editor before saving queries."],"tags":["lucene","query-dsl","fuzzy"],"backgroundTag":"missing-required-argument","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"}