# First query is slow after every short period of time

**URL:** https://discuss.elastic.co/t/first-query-is-slow-after-every-short-period-of-time/246591
**Category:** Elasticsearch
**Created:** [August 27, 2020, 9:32am UTC](https://discuss.elastic.co/t/first-query-is-slow-after-every-short-period-of-time/246591 "2020-08-27T09:32:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Abhishek\_Chauhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhishek_chauhan/32/45475_2.png) [@Abhishek\_Chauhan](https://discuss.elastic.co/u/Abhishek_Chauhan)
#### Post date: [August 27, 2020, 9:32am UTC](https://discuss.elastic.co/t/first-query-is-slow-after-every-short-period-of-time/246591/1 "2020-08-27T09:32:35Z")

</div>

Hi,

I am using Elasticsearch version 7.6.2 inside a docker container and i use logstash to index data to my ES Node but when i query the ES indexes after a short amount of time, it takes a significant time to return search results but subsequent queries are very fast.  
For e.g. if time difference between two queries is 20 min, it takes up-to 3-4 secs to get back the results but if i query after 30 secs, it takes around 0.1 sec. What is more worrying that if i don't query it for 2-3 days, it took around 10secs to get back the results.  
I have around 3300 docs in my 4 indexes and 3000 of them in a single index.  
My query looks like this :

```auto
{
	"query": {
		"bool": {
			"filter": {
				"term": {
					"orgid.keyword": "43c5974b-c6e2-418f-b41c-567450ca7e9f"
				}
			},
			"must": {
				"query_string": {
					"analyze_wildcard": true,
					"fields": ["name"],
					"query": "*s_8*",
					"rewrite": "scoring_boolean"
				}
			}
		}
	}
}

```

and the index template :

```auto
{
    "template": "object",
    "index_patterns" : ["ap*", "ar*", "dg*", "de*"],
    "order" : 1,
    "settings" : {
        "number_of_shards" : 1,
        "search.idle.after" : "1800s",
        "refresh_interval" : "65s",
        "analysis": {
            "analyzer": {
                "case_insensitive": {
                    "tokenizer": "keyword",
                    "filter": [
                    "lowercase"
                    ]
                }
            }
        }
    },
    "mappings": {
        "properties": {
              "name": {
                "type" : "text",
                "analyzer": "case_insensitive",
                "fielddata": true
            }
           
        }
     }
}

```

i index docs after every 60sec. I tried search.idle.after, refresh\_interval and fielddata but they didn't help me much

---

<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: [September 24, 2020, 9:32am UTC](https://discuss.elastic.co/t/first-query-is-slow-after-every-short-period-of-time/246591/2 "2020-09-24T09:32:52Z")

</div>

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