# How to create intentionally slow query?

**URL:** <https://discuss.elastic.co/t/how-to-create-intentionally-slow-query/239132>\
**Category:** Elasticsearch\
**Created:** [June 29, 2020, 2:56pm UTC](https://discuss.elastic.co/t/how-to-create-intentionally-slow-query/239132 "2020-06-29T14:56:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trex/32/34230_2.png) [@trex](https://discuss.elastic.co/u/trex)\
**Post date:** [June 29, 2020, 2:56pm UTC](https://discuss.elastic.co/t/how-to-create-intentionally-slow-query/239132/1 "2020-06-29T14:56:25Z")

</div>

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

I thought it can be done via script

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

```

But it fails with error

```auto
{
  "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
        }
      },
...

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 27, 2020, 3:07pm UTC](https://discuss.elastic.co/t/how-to-create-intentionally-slow-query/239132/2 "2020-07-27T15:07:34Z")

</div>

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