OrchardCMS/OrchardCore · error · ArgumentException
Missing value in match phrase query
Error message
Missing value in match phrase query
What it means
MatchPhraseQueryProvider.CreateQuery supports an object form for match_phrase queries that requires a "value" property. If the object under the field name lacks "value", no phrase can be tokenized and the provider throws this ArgumentException.
Solutions
- Add the required "value" string property: {"title": {"value": "quick fox", "slop": 2}}.
- Check for key typos (exactly "value").
- Validate the object contains a non-empty string "value" before calling CreateQuery.
Example fix
// before
{"title": {"slop": 2}}
// after
{"title": {"value": "quick brown fox", "slop": 2}} Defensive patterns
Strategy: validation
Validate before calling
if (query.Value.ValueKind == JsonValueKind.Object && !query.Value.TryGetProperty("value", out _))
throw new ArgumentException("match_phrase query object requires a 'value' property"); Type guard
static bool HasPhraseValue(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("Match phrase query requires { \"value\": \"phrase text\" }."); } Prevention
- Always include "value" in object-form match_phrase queries.
- Use constants for query keys to avoid typos like "val".
- Validate required fields before submitting queries from client UIs.
When it happens
Trigger: Calling CreateQuery with a query like {"title": {"slop": 2}} — an object missing the required "value" key.
Common situations: Hand-written query JSON with typos in the value key; programmatically built queries that set only options like slop or analyzer; template rendering that dropped the value.
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 wildcard query
- Missing value in fuzzy query
- Invalid wildcard query
- Query DSL requires a [query] property
- Invalid property ' ' in boolean query
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/61dbe3a1697b9ca8.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/MatchPhraseQueryProvider.cs:33
}
var first = query.First();
var phraseQuery = new PhraseQuery();
JsonNode value;
switch (first.Value.GetValueKind())
{
case JsonValueKind.String:
value = first.Value;
break;
case JsonValueKind.Object:
var obj = first.Value.AsObject();
if (!obj.TryGetPropertyValue("value", out value))
{
throw new ArgumentException("Missing value in match phrase query");
}
// TODO: read "analyzer" property
if (obj.TryGetPropertyValue("slop", out var slop))
{
phraseQuery.Slop = slop.Value<int>();
}
break;
default: throw new ArgumentException("Invalid wildcard query");
}
foreach (var term in LuceneQueryService.Tokenize(first.Key, value.Value<string>(), context.DefaultAnalyzer))
{
phraseQuery.Add(new Term(first.Key, term));
}
View on GitHub (pinned to 4306c0717f)