Skip to main content

Elasticsearch Query Builder

Generate Elasticsearch DSL queries for match, term, range, and bool searches.

Written by Golam Rabbani, Founder & Lead Engineer

Maximum results returned

How to use this elasticsearch query builder

  1. Enter the index name (lowercase letters, digits, and -_.+* are allowed).
  2. Pick a query type: match, term, range, or bool.
  3. Fill in the field and value for match/term, gte/lte for range, or field=value clauses for bool.
  4. Set the size — the maximum number of hits to return.
  5. Press Generate to emit the HTTP request line plus the search body JSON.

About this elasticsearch query builder

The Elasticsearch query builder produces the exact request body shape Elasticsearch expects on the _search endpoint, plus the matching HTTP GET line. Match queries run analysis on the value (good for full-text search). Term queries skip analysis and coerce numeric or boolean literals so {term: {status: 1}} keeps the integer 1 instead of the string "1". Range queries accept any combination of gte and lte. Bool queries compose simple match clauses across must, should, and must_not — perfect for the typical "all of these and none of those" recipe.

Worked example: pick bool, set index to "logs-2026.05", must to "status=published, title=elasticsearch", must_not to "draft=true", and size to 20. The tool emits: GET /logs-2026.05/_search { "query": { "bool": { "must": [ { "match": { "status": "published" } }, { "match": { "title": "elasticsearch" } } ], "must_not": [ { "match": { "draft": "true" } } ] } }, "size": 20 }

Paste it into Kibana DevTools, _search via curl, or any Elasticsearch client. Generation is purely local.

FAQ

What is the difference between match and term?
match runs the field analyzer over the value, so "Hello World" becomes ["hello", "world"] — perfect for full-text search on analyzed text fields. term skips analysis and matches the exact value, useful for keyword fields, IDs, booleans, and numbers.
How do bool clauses work?
must = all of these must match (AND), should = at least one of these should match (boosts score), must_not = none of these may match (NOT). Provide a comma-separated list of field=value pairs per slot.
Does it support nested or geo queries?
Not in this version. The builder targets the four most-used clause types. For nested, geo, or function-score queries, generate the simpler skeleton here and extend by hand.
Why does my term query keep showing strings as quoted?
Term coerces input that matches an integer, float, or boolean literal. If your value is "true" the builder emits the boolean true; otherwise it is a string. Use match for analyzed text fields where the value is naturally a phrase.
Does it run the query?
No. Only the request body and the GET line are produced. You execute them yourself, which keeps your cluster URL and API keys off this page.
Is the index name validated?
Yes — against the lower-case, dash/dot/underscore/plus/asterisk character set Elasticsearch accepts for index names. Invalid characters block the build with an explanation.