{"record":{"id":"1f1ee344bffcc739","repo":"OrchardCMS/OrchardCore","slug":"invalid-fuzzy-query","errorCode":null,"errorMessage":"Invalid fuzzy query","messagePattern":"Invalid fuzzy query","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/FuzzyFilterProvider.cs","lineNumber":58,"sourceCode":"\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\n                break;\n            default: throw new ArgumentException(\"Invalid fuzzy query\");\n        }\n\n        booleanQuery.Add(fuzzyQuery, Occur.MUST);\n        var queryFilter = new QueryWrapperFilter(fuzzyQuery);\n\n        return new FilteredQuery(booleanQuery, queryFilter);\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":67,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/FuzzyFilterProvider.cs#L40-L67","documentation":"The fuzzy filter provider accepts the fuzzy value only as an object with a 'value' property (plus optional fuzziness/prefix_length/max_expansions/boost). Any other JSON kind (string, array, etc.) hits the default case and throws 'Invalid fuzzy query'.","triggerScenarios":"Using {\"fuzzy\":{\"field\":\"text\"}} (string shorthand) or an array as the fuzzy value.","commonSituations":"Porting Elasticsearch queries that permit the shorthand string form for fuzzy.","solutions":["Use the object form: {\"fuzzy\":{\"field\":{\"value\":\"text\",\"fuzziness\":\"AUTO\"}}}.","Never pass a raw string or array as the fuzzy value.","Validate the fuzzy node's JSON kind is Object before sending."],"exampleFix":"// before\n{\"fuzzy\":{\"title\":\"orchard\"}}\n// after\n{\"fuzzy\":{\"title\":{\"value\":\"orchard\"}}}","handlingStrategy":"type-guard","validationCode":"if (fuzzyValue is not JsonObject)\n    throw new ArgumentException(\"Fuzzy value must be an object like {\\\"value\\\":\\\"text\\\"}.\");","typeGuard":"static bool IsFuzzyObject(JsonNode? n) => n is JsonObject o && o.ContainsKey(\"value\");","tryCatchPattern":"try { return CreateFilteredQuery(...); }\ncatch (ArgumentException ex) when (ex.Message == \"Invalid fuzzy query\") { log.LogWarning(\"Bad fuzzy filter shape\"); }","preventionTips":["Convert ES-style string shorthand to the object form when importing queries.","Keep a small DSL schema validator for query JSON in your app."],"tags":["lucene","query-dsl","fuzzy"],"backgroundTag":"invalid-argument-format","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"}