GraphQL to Elasticsearch Converter Online — Convert GraphQL Queries to ES DSL
Paste your GraphQL query above and get the equivalent Elasticsearch DSL request. It converts field selections to _source filters, arguments to bool query conditions, and pagination args to size/from — all processed entirely in your browser.
How to Convert GraphQL to Elasticsearch — Step-by-Step
Input Your GraphQL Query
Building an Elasticsearch backend for your GraphQL API? Paste your query from a GraphiQL playground, Apollo Explorer, or application code.
.graphql or .gql fileAutomatic Conversion
The converter maps GraphQL concepts to Elasticsearch Search API:
GET /index/_search_source arraymatch conditions, numbers and booleans become term, lists become termssort, size, fromCopy or Download
elasticsearch-query.txtFrequently Asked Questions
How does a GraphQL query map to Elasticsearch?
Each top-level field is read as an index name, so products(status: "active") { name price } becomes GET /products/_search with a bool query on status and a _source list of name and price. A nested selection such as address { city } is treated as an object inside the document and becomes address.city in _source. Elasticsearch only accepts lowercase index names that do not start with an underscore, so Products or _logs are changed to products and logs, with a comment above the request saying so.
Which arguments become match, term, terms or range?
Strings and enum values become match clauses, numbers and booleans become term clauses, and lists become terms. An object made only of gt, gte, lt and lte, like price: { gte: 10, lte: 100 }, becomes a range clause. Any other object is read field by field, so address: { city: "Oslo" } matches address.city. A null value becomes a must_not exists check.
How are sorting and pagination handled?
orderBy and sortBy become sort. They can be a string such as "price DESC", an object such as { price: DESC, name: ASC }, or a list of those. limit and first become size, offset and skip become from. Everything else ends up in the query.
Are long IDs and decimals kept exactly?
Yes. The JSON body is written straight from the text of your query, so an ICCID like 8901240544102066246 stays a bare number with every digit, 14.50 stays 14.50, and a quoted value such as "00501" stays a string. Strings with quotes, backslashes or emoji are escaped so the body is valid JSON.
Can it convert mutations, variables or fragments?
Fragments and inline fragments are expanded into the fields they contain, and comments are ignored. Mutations and subscriptions are refused with a message, since they have no _search equivalent. A variable such as $id has no value inside the query text, so you are asked to replace it with the real value first.
Does my query leave the browser?
No. The query is parsed with the graphql-js library inside your browser and nothing is uploaded. The result is plain text in the Kibana Dev Tools format, so Download saves it as elasticsearch-query.txt. It costs nothing and needs no account.
Also try: GraphQL to SQL, GraphQL to MongoDB, MongoDB to GraphQL, GraphQL to REST, GraphQL Formatter.
Related Tools
GraphQL Query Formatter
Format and beautify GraphQL queries and schemas with syntax highlighting
GraphQL Schema Validator
Validate GraphQL schemas with syntax and structure checking
GraphQL Fixer
Fix broken GraphQL queries and schemas automatically, repair syntax errors and malformed types
GraphQL to TypeScript
Generate TypeScript types from GraphQL schemas and queries
GraphQL Minifier
Compress and optimize GraphQL queries for production
GraphQL to JSON Schema
Convert GraphQL schemas to JSON Schema format