OrchardCMS/OrchardCore · error · ArgumentException
Invalid wildcard query
Error message
Invalid wildcard query
What it means
Reached at the end of Lucene's WildcardQueryProvider.CreateQuery when the query fragment matched neither the single-term shape nor the object shape with a 'value' property (and any earlier validation already passed). It indicates a wildcard query clause whose JSON structure is unrecognized — for example an array of terms or a property other than 'value'/'boost'.
Solutions
- Convert the value to a string: {"wildcard": {"Rating": "5"}}.
- Use the object form with "value": {"Rating": {"value": "5*"}}.
- Coerce/validate JSON values to string kind before building the query.
Example fix
// before
{"wildcard": {"Price": 199}}
// after
{"wildcard": {"Price": "199*"}} Defensive patterns
Strategy: validation
Validate before calling
if (wild.ValueKind != JsonValueKind.String && wild.ValueKind != JsonValueKind.Object)
throw new InvalidOperationException("Wildcard value must be a string or an object with 'value'."); Type guard
static bool IsValidWildcardValue(JsonElement el) =>
el.ValueKind == JsonValueKind.String ||
(el.ValueKind == JsonValueKind.Object && el.TryGetProperty("value", out var v) && v.ValueKind == JsonValueKind.String); Try / catch
catch (ArgumentException ex) when (ex.Message == "Invalid wildcard query")
{
// coerce value to string and retry or reject query
} Prevention
- Coerce numeric/boolean wildcard values to strings before building queries.
- Remember Lucene wildcards operate on text; stringify numbers explicitly.
- Validate query JSON shape in a central query-builder helper.
When it happens
Trigger: Calling CreateQuery with a wildcard query whose value is not a string or object, e.g. {"wildcard": {"Rating": 5}} or a null/numeric wildcard value.
Common situations: Assuming wildcard queries accept numbers or pre-serialized values; dynamic query construction that doesn't coerce values to strings.
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
- Missing value in wildcard query
- Missing value in wildcard query
- Invalid wildcard query
- The terms lookup query is not supported
- Invalid terms query
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/492d891cf5ef0eee.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/WildcardQueryProvider.cs:41
case JsonValueKind.Object:
var obj = first.Value.AsObject();
if (!obj.TryGetPropertyValue("value", out var value))
{
throw new ArgumentException("Missing value in wildcard query");
}
var wildCardQuery = new WildcardQuery(new Term(first.Key, value.Value<string>()));
if (obj.TryGetPropertyValue("boost", out var boost))
{
wildCardQuery.Boost = boost.Value<float>();
}
return wildCardQuery;
default: throw new ArgumentException("Invalid wildcard query");
}
}
}
View on GitHub (pinned to 4306c0717f)