Run an ES|QL query

POST /_query

Get search results for an ES|QL (Elasticsearch query language) query.

External documentation

Query parameters

  • format string

    A short version of the Accept header, e.g. json, yaml.

    Values are csv, json, tsv, txt, yaml, cbor, smile, or arrow.

  • The character to use between values within a CSV row. Only valid for the CSV format.

  • Should columns that are entirely null be removed from the columns and values portion of the results? Defaults to false. If true then the response will include an extra section under the name all_columns which has the name of all columns.

  • If true, partial results will be returned if there are shard failures, but the query can continue to execute on other clusters and shards.

application/json

Body Required

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • took number

      Time unit for milliseconds

    • is_partial boolean
    • all_columns array[object]
      Hide all_columns attributes Show all_columns attributes object
    • columns array[object] Required
      Hide columns attributes Show columns attributes object
    • values array[array] Required

      A field value.

      A field value.

    • Hide _clusters attributes Show _clusters attributes object
    • profile object

      Profiling information. Present if profile was true in the request. The contents of this field are currently unstable.

POST /_query
curl \
 --request POST 'http://api.example.com/_query' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '"{\n  \"query\": \"\"\"\n    FROM library,remote-*:library\n    | EVAL year = DATE_TRUNC(1 YEARS, release_date)\n    | STATS MAX(page_count) BY year\n    | SORT year\n    | LIMIT 5\n  \"\"\",\n  \"include_ccs_metadata\": true\n}"'
Request example
Run `POST /_query` to get results for an ES|QL query.
{
  "query": """
    FROM library,remote-*:library
    | EVAL year = DATE_TRUNC(1 YEARS, release_date)
    | STATS MAX(page_count) BY year
    | SORT year
    | LIMIT 5
  """,
  "include_ccs_metadata": true
}
Response examples (200)
{
  "": 42.0,
  "is_partial": true,
  "all_columns": [
    {
      "name": "string",
      "type": "string"
    }
  ],
  "columns": [
    {
      "name": "string",
      "type": "string"
    }
  ],
  "values": [
    [
      42.0
    ]
  ],
  "_clusters": {
    "total": 42.0,
    "successful": 42.0,
    "running": 42.0,
    "skipped": 42.0,
    "partial": 42.0,
    "failed": 42.0,
    "details": {
      "additionalProperty1": {
        "status": "running",
        "indices": "string",
        "": 42.0,
        "_shards": {
          "total": 42.0,
          "successful": 42.0,
          "skipped": 42.0,
          "failed": 42.0,
          "failures": [
            {}
          ]
        }
      },
      "additionalProperty2": {
        "status": "running",
        "indices": "string",
        "": 42.0,
        "_shards": {
          "total": 42.0,
          "successful": 42.0,
          "skipped": 42.0,
          "failed": 42.0,
          "failures": [
            {}
          ]
        }
      }
    }
  },
  "profile": {}
}