Dev
Mock Elasticsearch Query 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 query DSL object as JSON with no inputs required. Each query contains a bool query with a must clause (a match on one of title, description, content, or name), a filter array with a term clause (on status) and a range clause (created_at in the last 7 days using date math), a sort by created_at descending, and a size of 10, 20, or 50. The field names and terms are randomised each run. Copy the JSON 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
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- 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 bool query with a must array (one match clause on a random field), a filter array (a term clause on status and a range clause on created_at using now-7d/d date math), a sort by created_at descending, and a size of 10, 20, or 50. Field names and values are randomised each run.
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 field names (title, status, created_at) must exist in your index mapping with compatible types — created_at must be a date field for the range to work, and status should be a keyword for the term query. Use it to learn the DSL structure, then swap in your real field names.
You might also like
Popular tools from other categories that share themes with this one.
Try these next
More free tools from other corners of the catalog, picked by shared themes.