OrchardCMS/OrchardCore · error · ArgumentException
Prefix query misses prefix value
Error message
Prefix query misses prefix value
What it means
PrefixQueryProvider.CreateQuery builds a Lucene PrefixQuery from a JSON query node. When the node's type is 'prefix' but the JSON object contains no 'prefix' property, there is no value to build the Term from, so the provider throws ArgumentException. The 'prefix' property holding the prefix string is mandatory for this query type.
Solutions
- Add the required "prefix" string property to the query JSON object, e.g. {"Title": {"type": "prefix", "prefix": "Orch"}}.
- Verify the property is named exactly 'prefix' (case-sensitive) and is a JSON string.
- If the query came from a saved query or recipe, fix it in the admin UI Queries editor and re-save.
Example fix
// before
{"Content.ContentItem.Text": {"type": "prefix"}}
// after
{"Content.ContentItem.Text": {"type": "prefix", "prefix": "Orch"}} Defensive patterns
Strategy: validation
Validate before calling
if (node is JsonObject obj && obj.TryGetPropertyValue("prefix", out var p) && p is JsonValue pv && pv.TryGetValue<string>(out var prefix) && !string.IsNullOrEmpty(prefix)) { /* safe to call */ } Type guard
static bool HasPrefixValue(JsonNode node) => node is JsonObject o && o.TryGetPropertyValue("prefix", out var p) && p.GetValueKind() == JsonValueKind.String; Try / catch
try { var q = provider.CreateQuery(node); } catch (ArgumentException ex) when (ex.Message == "Prefix query misses prefix value") { // surface a 'prefix value required' validation message } Prevention
- Always include both "type": "prefix" and "prefix": "..." in prefix query JSON.
- Validate query JSON against the expected schema before submitting.
- Prefer the Queries admin UI editor over hand-editing recipe JSON.
When it happens
Trigger: Calling CreateQuery with a JSON node like {"field": {"type": "prefix"}} — the object has type 'prefix' but lacks the required "prefix" string property.
Common situations: Hand-written Lucene query JSON in Queries/UI missing the prefix value; recipes or saved queries exported from an older schema where the property was named differently; typos like 'preifx' or 'Prefix'.
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
- Invalid term in terms query
- Invalid terms query
- Invalid wildcard query
- Invalid fuzzy query
- Invalid query
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/bf652780fadf3af7.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/PrefixQueryProvider.cs:40
{
case JsonValueKind.String:
return new PrefixQuery(new Term(first.Key, first.Value.ToString()));
case JsonValueKind.Object:
var obj = first.Value.AsObject();
PrefixQuery prefixQuery;
if (obj.TryGetPropertyValue("value", out var value))
{
prefixQuery = new PrefixQuery(new Term(first.Key, value.Value<string>()));
}
else if (obj.TryGetPropertyValue("prefix", out var prefix))
{
prefixQuery = new PrefixQuery(new Term(first.Key, prefix.Value<string>()));
}
else
{
throw new ArgumentException("Prefix query misses prefix value");
}
if (obj.TryGetPropertyValue("boost", out var boost))
{
prefixQuery.Boost = boost.Value<float>();
}
return prefixQuery;
default: throw new ArgumentException("Invalid prefix query");
}
}
}
View on GitHub (pinned to 4306c0717f)