Mock Elasticsearch Query Generator
Generates example Elasticsearch query DSL JSON for testing and learning
Generated 73 words · 447 characters
See 3 examples
- Example 1
GET /orders-2026/_search { "size": 10, "from": 100, "query": { "bool": { "must": [ { "match_phrase": { "notes": "leave at the back door" } } ], "filter": [ { "terms": { "currency": [ "EUR", "GBP", "SEK" ] } } ], "must_not": [ { "term": { "customer.id": "cus_29684" } } ] } }, "aggs": { "by_id": { "terms": { "field": "customer.id", "size": 5 } }, "avg_count": { "avg": { "field": "items.count" } } } } - Example 2
GET /careers/_search { "size": 0, "query": { "bool": { "must": [ { "multi_match": { "query": "flexible hours", "fields": [ "title^2", "description" ] } } ], "filter": [ { "range": { "posted_at": { "gte": "now-89d/d", "lt": "now/d" } } } ], "should": [ { "match_phrase": { "title": "data analyst" } }, { "exists": { "field": "seniority" } } ], "minimum_should_match": 1 } }, "aggs": { "sum_salary_min": { "sum": { "field": "salary_min" } }, "by_seniority": { "terms": { "field": "seniority", "size": 3 } } } } - Example 3
GET /products-catalog/_search { "size": 10, "query": { "bool": { "must": [ { "match": { "description": "long battery life" } } ], "filter": [ { "term": { "tags": "eco" } } ] } }, "_source": [ "rating", "created_at" ] }
About this generator
Elasticsearch's query DSL is expressive but has a steep learning curve — must vs. filter, term vs. match, and the nested bool structure are not obvious until you see them in context. When you need a realistic query to test a parser, seed a search fixture, or paste into the Kibana Dev Tools console, writing one from scratch is fiddly. This tool generates a valid Elasticsearch search request with no inputs required. Each run picks one of fourteen realistic index types — application logs, orders, a product catalog, clickstream events, support tickets, users, help articles, payments, system metrics, inventory, job postings, recipes, property listings, and APM traces — and builds the request from that index's own fields, so a term filter always hits a keyword field, a range always hits a number or date, and full-text clauses only target text fields. Queries are either a single clause or a bool query mixing must (match, match_phrase with or without operator and fuzziness, multi_match with a boosted field), filter (term, terms, exists, numeric ranges, date-math or absolute date ranges), should with minimum_should_match, and must_not. Many requests also add sorting, _source filtering, highlighting, pagination with from, track_total_hits, and aggregations: terms, date_histogram, and avg/sum/min/max/stats/percentiles/cardinality metrics, sometimes nested as sub-aggregations. Copy the request into a test case, paste it into the Kibana console to learn how it executes, or use it to exercise code that constructs or proxies Elasticsearch requests. Adapt the index mapping and field names to your own data before running it on a real cluster.
How to use
- Click Generate to produce a query.
- Copy the JSON into a console or test.
- Adapt the fields and terms to your index.
- Run it after tailoring to your mapping.
Use Cases
- •Learning the Elasticsearch query DSL
- •Building a mock search query
- •Documenting a search feature
- •Testing a query parser
- •Seeding example queries
Tips
- →must affects relevance; filter does not.
- →filter clauses can be cached.
- →Adapt fields to your mapping.
- →Use date math like now-7d/d.
FAQ
what does the generated query contain
A GET <index>/_search request line followed by a JSON body. The index is one of fourteen realistic types (logs, orders, products, users, payments, metrics and more), and the body uses that index's fields: either a single clause or a bool query with must, filter, should and must_not clauses, plus optional sort, _source, highlight, from/size pagination, track_total_hits, and aggregations such as terms, date_histogram and metric aggs. Index names, fields, values, date-math windows and sizes vary every run, and each clause is printed on one line so the structure is easy to read.
what is the difference between must and filter in a bool query
Both narrow the result set, but must clauses contribute to the relevance _score while filter clauses do not and can be cached by Elasticsearch, making them faster. Use must for full-text match where scoring matters; use filter for exact conditions like status or date ranges where you only want yes/no matching.
what is the difference between a term and a match query
A term query looks for an exact, un-analysed value — it is used for keywords, IDs, and enums where the field is not tokenised. A match query runs the search term and the field through the same text analyser, enabling full-text search with tokenisation and stemming. Using term on an analysed text field is a common gotcha that returns no results.
can I run this query against my elasticsearch cluster directly
Only after adapting it. The fields must exist in your index mapping with compatible types — text fields for match queries, keyword fields (or .keyword sub-fields) for term, terms and aggregations, and date or numeric fields for ranges, sorting and histograms. Use it to learn the DSL structure, then swap in your real index and field names.
You might also like
Popular tools from other categories that share themes with this one.