Skip to content

Instantly share code, notes, and snippets.

@ycombinator
Last active April 24, 2019 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycombinator/a9973fec6e4bb62d908a19ee94b8968a to your computer and use it in GitHub Desktop.
Save ycombinator/a9973fec6e4bb62d908a19ee94b8968a to your computer and use it in GitHub Desktop.
ES script query

Request

POST .monitoring-kibana-*/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "type": "kibana_stats"
          }
        },
        {
          "script": {
            "script": {
              "lang": "painless", 
              "source": "params._source.kibana_stats.usage != null"
            }
          }
        }
      ]
    }
  }
}

Response

{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "params._source.kibana_stats.usage != null",
          "              ^---- HERE"
        ],
        "script": "params._source.kibana_stats.usage != null",
        "lang": "painless"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": ".monitoring-kibana-7-2019.04.24",
        "node": "AvRIyUMSRguzYmpxjUMnUQ",
        "reason": {
          "type": "script_exception",
          "reason": "runtime error",
          "script_stack": [
            "params._source.kibana_stats.usage != null",
            "              ^---- HERE"
          ],
          "script": "params._source.kibana_stats.usage != null",
          "lang": "painless",
          "caused_by": {
            "type": "null_pointer_exception",
            "reason": null
          }
        }
      }
    ]
  },
  "status": 400
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment