Query Lab

Elasticsearch Query Builder

Build production-ready Query DSL without wrestling with JSON: conditions, bool logic, sorting, aggregations, and mapping-aware checks, with a ready request for the API or Kibana.

Runs locallyYour mapping and queries stay in the browser
Quick start

Examples:

01 · BUILDERVisual builder
Query conditionsChoose the logic, query type, field, and value.
Which query type should I pick?

Quick cheat sheet: searching for words in text — match; an exact value (status, tag, ID) — term for one and terms for several; a range of numbers or dates — range; checking that a field is present — exists; pattern search — wildcard or prefix; typo-tolerant search — fuzzy; a complex expression with AND/OR — query_string; parenthesized logic like A AND (B OR C) — a nested bool group.

TypeWhen to useExample
matchFull-text search: the text is split into words and documents matching any of them are found (analyzer-aware). For text fields.title : wireless headphones
match_phraseExact phrase search: the words must appear consecutively and in the same order. For text fields.message : "out of memory"
termExact value match with no text analysis. For keyword, numbers, dates, and booleans; for text fields use the .keyword sub-field.status : published
termsExact match against any of the listed values — like IN in SQL. Values are comma-separated.status : draft, published
rangeA range of values: from (gte) and/or to (lte). Works for numbers and dates, supports expressions like now-7d.price : 100 … 500 / created_at : now-7d …
existsFinds documents where the field exists and is not null. No value required.email
wildcardPattern search: * matches any number of characters, ? matches one. Runs against the exact value (keyword); patterns starting with * are slow.host : web-*
prefixFinds values that start with the given string. For keyword fields.sku : AB-
fuzzyTypo-tolerant search (edit distance): "adidsa" will find "adidas".brand : adidsa → adidas
query_stringA Lucene-syntax expression: AND, OR, NOT, parentheses, quotes, field:value. Powerful but strict about syntax.(error OR warn) AND service:api
bool (group)A nested bool group: combines several conditions into one block — like parentheses in a logical expression. Needed for logic like A AND (B OR C); the same must / filter / should / must_not are available inside, and groups can be nested within each other.status:active AND (type:a OR type:b)

No conditions — a match_all query will be generated.

Advanced settings
JSON → BUILDER

Import an existing query

Paste a JSON body or a Kibana Dev Tools request. Common bool clauses, from/size, _source, sorts, and aggregations will be restored in the visual builder.

How a bool query works.

In Elasticsearch, conditions are combined inside a bool query: must works like AND and affects relevance scoring, filter works like AND without scoring (faster and cacheable), should works like OR, and must_not excludes documents. If only one must condition is set, the builder outputs it without the bool wrapper.

Full bool logic, no raw JSON

Build must, filter, should, must_not, and nested groups visually.

Mapping-aware checks

Catch missing fields, costly wildcards, and aggregations on text.

Round-trip workflow

Import existing DSL, adjust it visually, then copy JSON, cURL, or Kibana.

Free online Elasticsearch query builder. Compose Query DSL requests visually instead of writing JSON by hand: pick a query type (match, match_phrase, term, terms, range, exists, wildcard, prefix, fuzzy, query_string), specify the field and value, and choose the bool context — must, filter, should, or must_not. A built-in cheat sheet explains which query type to pick in each situation.

Paste your index mapping and the builder starts autocompleting field names and validating the query: it warns about term on a text field, match on keyword, sorting or aggregating on text, non-existent fields (with a "did you mean" suggestion), swapped range bounds, and other common mistakes. The tool also supports nested bool groups for logic like A AND (B OR C), automatic wrapping of conditions on nested fields in a nested query, sorting, from/size pagination, _source, track_total_hits, minimum_should_match, and aggregations: terms, avg, sum, min, max, cardinality, value_count, date_histogram, histogram. The result is available as JSON, cURL, or a Kibana Dev Tools snippet.

Everything runs locally in your browser — queries are not sent or stored anywhere. A handy tool for developers, DevOps engineers, and analysts working with Elasticsearch and OpenSearch: prototype a search query, debug a bool filter, or prepare an aggregation request in seconds.

Related tools