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

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

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


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.

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.

Could you share the response from elasticsearch?

this is how it looks, sample (dummy data)

  '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': '',
          '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

4ms is not that bad.

Could you share the full response when it looks bad?


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