Query DSL for Elasticsearchs
The Elasticsearch Query DSL is the JSON language used in the _search API to express queries. It separates full-text queries such as match, which are analyzed and scored, from term-level queries such as term and range, which match exact values, and combines them with the bool query.
Stage: Searching · Part of the Elasticsearch roadmap · Last reviewed 19 November 2026
What to learn in Query DSL
- Write a match query and a match_phrase query and compare their results
- Combine must, should, must_not and filter clauses inside a bool query
- Use term and range queries for exact and numeric or date filtering
- Paginate with from and size and know when to switch to search_after
- Sort results by a field and request only needed fields with _source filtering
Query DSL interview questions
What is the difference between must and filter in a bool query?
Both require a document to match, but must clauses contribute to the relevance score while filter clauses do not. Filters are also cacheable and faster, so exact conditions like status or date ranges belong in filter.
Why is deep pagination with from and size a problem?
Each shard must build and sort from plus size hits, and the coordinating node merges them, so memory and time grow with depth. Elasticsearch caps this by default at 10,000 results. For deep paging, use search_after with a point in time.
Where Query DSL fits in the Elasticsearch roadmap
Query DSL belongs to the Searching stage (intermediate level), which takes about 15 hours. Queries and relevance.
Other units in this stage
Back to the full Elasticsearch roadmap