OrchardCMS/OrchardCore · error · ArgumentException
Missing value in fuzzy query
Error message
Missing value in fuzzy query
What it means
FuzzyQueryProvider.CreateQuery supports an object form for fuzzy queries that requires a "value" property. If the object under the field name has no "value" key, the provider cannot build a FuzzyQuery and throws this ArgumentException.
Solutions
- Add the required "value" string property: {"title": {"value": "werd", "fuzziness": 2}}.
- Verify the key is exactly "value" (case-sensitive).
- Validate the object contains a string "value" before calling CreateQuery.
Example fix
// before
{"title": {"fuzziness": 2}}
// after
{"title": {"value": "werd", "fuzziness": 2}} Defensive patterns
Strategy: validation
Validate before calling
if (query.Value.ValueKind == JsonValueKind.Object && !query.Value.TryGetProperty("value", out _))
throw new ArgumentException("fuzzy query object requires a 'value' property"); Type guard
static bool HasFuzzyValue(JsonElement el) =>
el.ValueKind == JsonValueKind.Object && el.TryGetProperty("value", out var v) && v.ValueKind == JsonValueKind.String; Try / catch
try { var query = provider.CreateQuery(context, queryJson); }
catch (ArgumentException ex) when (ex.Message.Contains("Missing value"))
{ return BadRequest("Fuzzy query requires { \"value\": \"term\" }."); } Prevention
- Always set "value" in object-form fuzzy queries alongside fuzziness/prefix_length.
- Use typed DTOs with required members to build query JSON.
- Validate required keys before calling CreateQuery.
When it happens
Trigger: Calling CreateQuery with a filter like {"title": {"fuzziness": 2}} — an object missing the required "value" key.
Common situations: Typo'd keys ("val", "term") in hand-written queries; programmatically built query objects where only tuning options (fuzziness, prefix_length) were set; mixing term and fuzzy query syntaxes.
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
- Missing value in fuzzy query
- Invalid fuzzy query
- Missing value in wildcard query
- Invalid fuzzy query
- Missing value in match phrase query
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/005bb4fb28d72f68.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/FuzzyQueryProvider.cs:30
{
if (type != "fuzzy")
{
return null;
}
var first = query.First();
switch (first.Value.GetValueKind())
{
case JsonValueKind.String:
return new FuzzyQuery(new Term(first.Key, first.Value.ToString()));
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);
var 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)