Reference Entry
WildcardQuery for Term-Level Pattern Matching
Lexical Querying · advanced · order 70
Match indexed terms with `*` and `?` patterns without switching to full-text analysis, using the JSON DSL first.
Relevant APIs
WildcardQuery for Term-Level Pattern Matching
wildcard matches indexed terms using simple wildcard syntax:
*matches zero or more characters?matches exactly one character
This is a term-level query. It works against analyzed terms that already exist in the index.
Basic example
{
"query": {
"wildcard": {
"title": "que*"
}
}
}
When to use it
- Match families of tags or codes.
- Support simple power-user patterns.
- Search normalized keyword-like values with a little flexibility.
Wildcard vs MatchQuery
matchanalyzes the input text and uses lexical ranking.wildcardchecks indexed terms directly.
If you want normal search-box behavior, use match.
If you want pattern matching over already-indexed terms, use wildcard.
Notes
- Wildcards operate on analyzed terms, not raw source strings.
- Broad leading wildcards such as
*lightmay match many terms. - For simple prefix use cases,
PrefixQueryis usually clearer.