OrchardCMS/OrchardCore · error · ArgumentException
Missing value in regexp query
Error message
Missing value in regexp query
What it means
RegexpQueryProvider.CreateQuery builds a Lucene RegexpQuery from a JSON object node. The 'value' property containing the regular expression is mandatory; if the object lacks it, the provider throws ArgumentException. The regexp pattern is what defines the term match, so it cannot be defaulted.
Solutions
- Add the required "value" string property with the regular expression, e.g. {"Title": {"type": "regexp", "value": "Orch.*"}}.
- Rename any 'pattern'/'regex' keys to exactly "value".
- Validate the query JSON shape before submitting it to the Lucene query provider.
Example fix
// before
{"Title": {"type": "regexp", "pattern": "Orch.*"}}
// after
{"Title": {"type": "regexp", "value": "Orch.*"}} Defensive patterns
Strategy: validation
Validate before calling
if (node is JsonObject o && o.TryGetPropertyValue("value", out var v) && v.GetValueKind() == JsonValueKind.String && !string.IsNullOrEmpty(v.GetValue<string>())) { /* safe to call */ } Type guard
static bool HasRegexpValue(JsonNode node) => node is JsonObject o && o.TryGetPropertyValue("value", out var v) && v.GetValueKind() == JsonValueKind.String; Try / catch
try { var q = provider.CreateQuery(node); } catch (ArgumentException ex) when (ex.Message == "Missing value in regexp query") { // report 'regexp value required' to the user } Prevention
- Always set the "value" property with the pattern in regexp query JSON.
- Use "value" (not "pattern"/"regex") as the property name.
- Validate regexp queries in the query editor before saving.
When it happens
Trigger: A query node like {"field": {"type": "regexp"}} or {"field": {"type": "regexp", "boost": 2}} — type is regexp but the "value" property with the pattern is absent.
Common situations: Hand-written query JSON omitting the pattern; recipes migrated from other search providers using a different property name (e.g. 'pattern' or 'regex'); typos in the property name.
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 regexp query
- Prefix query misses prefix value
- Invalid fuzzy query
- Invalid fuzzy query
- Invalid geo point representation
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/1a4f0aebe5cb4e1d.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/RegexpQueryProvider.cs:29
{
if (type != "regexp")
{
return null;
}
var first = query.First();
switch (first.Value.GetValueKind())
{
case JsonValueKind.String:
return new RegexpQuery(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 regexp query");
}
// TODO: Support flags
var regexpQuery = new RegexpQuery(new Term(first.Key, value.Value<string>()));
if (obj.TryGetPropertyValue("boost", out var boost))
{
regexpQuery.Boost = boost.Value<float>();
}
return regexpQuery;
default: throw new ArgumentException("Invalid regexp query");
}
}
}
View on GitHub (pinned to 4306c0717f)