Elasticsearch Query DSL Builder
Write bool-query clauses one per line, such as filter term status published, and get the Elasticsearch JSON body plus a curl command. Add sort, source filtering, a terms aggregation and highlight.
Use the tool
Why this tool exists
Elasticsearch queries are nested JSON, and a simple search with two filters and a range already takes several levels of braces. Typing them in Kibana or curl is slow, and a misplaced bracket gives an error that is not helpful.
Here you write each condition as one line: the occur type (must, filter, should, must_not), the clause type and the field and value. The tool builds the bool query, adds size, from, sort, _source and an optional terms aggregation, and prints both the request body and a curl command. It supports the common clause types: match, match_phrase, term, terms, range, exists, prefix, wildcard, fuzzy and multi_match. More advanced queries need hand editing. Nothing is sent anywhere.
How to use it
- Write one clause per line, for example filter term status published.
- Set the index, size, from, sort and the fields to include in _source.
- Optionally enter a field for a terms aggregation and choose a highlight field.
- Copy the JSON body or the curl command.
Frequently asked questions
What does each occur type do?
must clauses must match and affect scoring, filter clauses must match without scoring, should clauses are optional boosts, and must_not clauses exclude documents.
How do I write a range?
Use key=value pairs, for example filter range price gte=10 lte=100. Supported keys are gt, gte, lt, lte, format and time_zone.
Does it send the query?
No. It produces text only. The curl command points at localhost:9200 as an example, so change the host and add authentication before running it.
Which clause types are supported?
match, match_phrase, term, terms, range, exists, prefix, wildcard, fuzzy and multi_match. For nested, geo or script queries, edit the generated JSON by hand.