Skip to main content
Back to Dev generators

Dev

Mock Elasticsearch Query Generator

Used by developers, writers, and creators worldwide.

A mock Elasticsearch query generator produces example query DSL in JSON for testing, learning, and documentation. Elasticsearch queries are written as nested JSON with their own structure — bool queries, must and filter clauses, ranges, and sorts — and a realistic sample is the fastest way to learn the DSL or test a parser. This tool emits a valid query combining a match, filters, a date range, and a sort. Click generate and copy it into a test, a console, or a tutorial. It is ideal for learning the Elasticsearch query DSL, building a mock search, and documenting a query. The JSON follows the real DSL structure, so it shows how clauses nest — a bool query with must and filter, a range with date math, and a sort. Adapt the fields, terms, and clauses to your own index and mapping before running it against a real cluster.

Loading usage…

Free forever — no account required

How to use

  1. Choose your options above
  2. Click Generate
  3. Copy your result

Detailed instructions

  1. Click Generate to produce a query.
  2. Copy the JSON into a console or test.
  3. Adapt the fields and terms to your index.
  4. 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 is the Elasticsearch query DSL

It is the JSON-based language Elasticsearch uses to express searches, with constructs like bool queries, match and term clauses, ranges, and sorts. Queries nest these together, and this tool generates a realistic sample of that structure.

what is the difference between must and filter

Both narrow results, but must clauses contribute to the relevance score while filter clauses do not and can be cached, making them faster for yes-or-no conditions like a status or date range. The sample uses each appropriately.

can i run this query directly

It is a learning and testing sample. Adapt the fields, terms, and clauses to match your own index and mapping first. The structure is correct DSL; the specific fields need to reflect your real data before it returns useful results.