Last updated
Elasticsearch Query DSL
Elasticsearch uses a JSON-based Query DSL (Domain Specific Language) for searching.
Queries are divided into two categories: leaf queries (match, term, range) that
search specific fields, and compound queries (bool, dis_max) that combine multiple
queries. Understanding the difference between query (affects scoring)
and filter (binary yes/no, cached) is key to performance.
Common Query Types
| Query | Use Case |
|---|---|
| match | Full-text search on analyzed fields |
| term | Exact value match (keyword fields) |
| range | Numeric or date range |
| bool | Combine queries with must/should/must_not/filter |
| multi_match | Search across multiple fields |
| wildcard | Pattern matching with * and ? |
| fuzzy | Approximate matching (typo tolerance) |
| nested | Query nested objects |
Bool Query Example
{
"query": {
"bool": {
"must": [
{ "match": { "title": "elasticsearch" } }
],
"filter": [
{ "term": { "status": "published" } },
{ "range": { "date": { "gte": "2026-01-01" } } }
],
"should": [
{ "match": { "tags": "search" } }
],
"must_not": [
{ "term": { "deleted": true } }
]
}
},
"sort": [
{ "date": { "order": "desc" } },
"_score"
],
"from": 0,
"size": 10
}