# How to decrease the response time for the first time call of Elasticsearch query?

**URL:** <https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361>\
**Category:** Elasticsearch\
**Created:** [September 16, 2021, 6:34am UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361 "2021-09-16T06:34:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavan\_kalyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pavan_kalyan/32/94647_2.png) [@pavan\_kalyan](https://discuss.elastic.co/u/pavan_kalyan)\
**Post date:** [September 16, 2021, 6:34am UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361/1 "2021-09-16T06:34:14Z")

</div>

sample query here, could anyone please help me to solve this issue.

```auto
query = {
    "size": 20,
    "_source": {
            "includes": ["xyz", "abc", 'dgs'],
        },
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "label": ids
                    }
                }
            ]
        }
    },
}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 16, 2021, 9:46am UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361/2 "2021-09-16T09:46:38Z")

</div>

Welcome!

The only way to decrease the very first response time for a given user is to warm a bit the indices and the underlying filesystem cache.  
How? By running some searches before making the search engine available to your users.

Or. Just let the very first users "suffering" from the response time. As soon as they will search again, it will be fast.

---

<div class="post-metadata">

**Author:** ![pavan\_kalyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pavan_kalyan/32/94647_2.png) [@pavan\_kalyan](https://discuss.elastic.co/u/pavan_kalyan)\
**Post date:** [September 16, 2021, 10:37am UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361/3 "2021-09-16T10:37:00Z")

</div>

okay fine, but Is there anything that can be done with query structure for the faster response of the search to get the data from index.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 16, 2021, 1:16pm UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361/4 "2021-09-16T13:16:58Z")

</div>

Could you share the response from elasticsearch?

---

<div class="post-metadata">

**Author:** ![pavan\_kalyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pavan_kalyan/32/94647_2.png) [@pavan\_kalyan](https://discuss.elastic.co/u/pavan_kalyan)\
**Post date:** [September 17, 2021, 9:05am UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361/5 "2021-09-17T09:05:30Z")

</div>

this is how it looks, sample (dummy data)

```auto
{
  'took': 4,
  'timed_out': False,
  '_shards': {
    'total': 5,
    'successful': 5,
    'skipped': 0,
    'failed': 0
  },
  'hits': {
    'total': {
      'value': 41,
      'relation': 'eq'
    },
    'max_score': 1.0,
    'hits': [
      {
        '_index': 'indexname',
        '_type': '_doc',
        '_id': '54g3v3tv3vt',
        '_score': 1.0,
        '_source': {
          'tweet_url': 'https://twitter.com/web/status/53422',
          'user_id': '5842',
          'username': 'htgfd',
          'date': '2021-06-02',
          'query': 'Anthony Fauci emails? “Subject: Coronavirus bio-weapon d.”\n(Page 2286)',
          'user_tweet_text': '@tgbvrf',
          'user_quoted_tweet_text': '"Hello Anthony, virus was created.”\n(Page 2286)',
          'parent_tweet_text': None,
          'user_quoted_tweet_user': 'EmpireExp',
          'parent_tweet_user': None,
          'parent_tweet_user1': None,
          'c0': -1,
          'c0': 1,
          'c': 116,
          'c0_1': 8,
          'c0_2': 116,
          'c0_2': 8,
          'theme': [
            {
              'word': 'bgvf',
              'weight': 0.32
            }
          ],
          'user_dominance_score': 0.125,
          'broadcaster_dominance_score': 0.375,
          'select_flag': 1
        }
      },
      
    }
}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 17, 2021, 7:54pm UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361/6 "2021-09-17T19:54:32Z")

</div>

4ms is not that bad.

Could you share the full response when it looks bad?

---

<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:** [October 15, 2021, 7:54pm UTC](https://discuss.elastic.co/t/how-to-decrease-the-response-time-for-the-first-time-call-of-elasticsearch-query/284361/7 "2021-10-15T19:54:57Z")

</div>

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