How to create intentionally slow query?

I want to test things with a slow query. How can I create a slow query?

I thought it can be done via script

GET _search
{
  "script_fields": {
    "AvgTicketPrice": {
      "script": "sleep(3000);"
    }
  }
}

But it fails with error

{
  "error" : {
    "root_cause" : [
      {
        "type" : "script_exception",
        "reason" : "compile error",
        "script_stack" : [
          "sleep(3000);",
          "^---- HERE"
        ],
        "script" : "sleep(3000);",
        "lang" : "painless",
        "position" : {
          "offset" : 0,
          "start" : 0,
          "end" : 12
        }
      },
...
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.