Elasticsearch Highlighting is very slow

Hi,
I find unified highlighting is taking a long time to fetch highlight results. I wish to know why there is huge difference when using highlighting
I am using "term_vector": "with_positions_offsets" on all the fields that has to be highlighted
My query is as below without highlight :

{
  "from": 0,
  "size": 24,
  "query": {
    "bool": {  "should": [
        { "bool": {
            "should": [
              { "query_string": {
                  "query": "\"tets\"",
                  "fields": [  ],
                  "boost": "50"
                }   },
              {"multi_match": {
                  "query": "tets",
                  "type": "phrase",
                  "boost": "10",
                  "slop": "2",
                  "fields": [  ] }  },
              { "multi_match": {
                  "query": "tets",
                  "fields": [   ] }},
              {"multi_match": {
                  "query": "tets",
                  "fuzziness": "AUTO",
                  "fields": [   ] }  } ],
            "minimum_should_match": 1,
            "filter": [
              {
                "bool": {
                  "should": [
                    { "query_string": {
                        "query": "place:(California OR AndheriY OR Mumbai) AND SUB_TYPE_ID:(4028b204580517120158052c8b0b04dd OR 4028b204580517120158052c8b1804e0)"
                      }   },
                    { "query_string": {
                        "query": "place:(California OR Germany OR Pune) AND SUB_TYPE_ID:(4028b204580517120158052c8b0b04dd OR 4028b204580517120158052c8b0f04de OR 4028b204580517120158052c8b1404df)"  } },
                    {"query_string": {
                        "query": " !_exists_:plcae AND SUB_TYPE_ID:(4028b204580517120158052c8b0b04dd OR 4028b204580517120158052c8b1804e0 OR 4028b204580517120158052c8b0f04de OR 4028b204580517120158052c8b1404df)"  }   }   ],
                  "minimum_should_match": 1
                }  },
               {
                "bool": {
                  "should": [
                    {
                      "query_string": {
                        "query": "status:(Yes ) "
                      }
                    },
                    {
                      "query_string": {
                        "query": "status:(No) AND user:(6901)"
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        }
      ],
      "minimum_should_match": 1,
      "filter": [
        {
          "terms": {
            "ACTIVE.keyword": [
              "1"
            ]
          }
        },
        {
          "terms": {
            "FOLDER_ID.keyword": [
              2,
              8,
              9,
              12,
              14,
              -1
            ]
          }
        }
      ]
    }
  }
}

It takes around 42ms.

My query with highlight is :

{
  "from": 0,
  "size": 24,
  "query": {
    "bool": {
      "should": [
        {"bool": {
            "should": [
              {
                "query_string": {
                  "query": "\"tets\"",
                  "fields": [   ],
                  "boost": "50"
                }
              },
              {
                "multi_match": {
                  "query": "tets",
                  "type": "phrase",
                  "boost": "10",
                  "slop": "2",
                  "fields": [   ]
                }
              },
              { "multi_match": {
                  "query": "tets",
                  "fields": [ ] }  },
              {"multi_match": {
                  "query": "tets",
                  "fuzziness": "AUTO",
                  "fields": [ ]          }    } ],
            "minimum_should_match": 1,
            "filter": [
              {
                "bool": {
                  "should": [
                    {
                      "query_string": {
                        "query": "place:(California OR AndheriY OR Mumbai) AND SUB_TYPE_ID:(4028b204580517120158052c8b0b04dd OR 4028b204580517120158052c8b1804e0)"
                      }
                    },
                    {
                      "query_string": {
                        "query": "place:(California OR Germany OR Pune) AND SUB_TYPE_ID:(4028b204580517120158052c8b0b04dd OR 4028b204580517120158052c8b0f04de OR 4028b204580517120158052c8b1404df)"
                      }
                    },
                    {
                      "query_string": {
                        "query": " !_exists_:place AND SUB_TYPE_ID:(4028b204580517120158052c8b0b04dd OR 4028b204580517120158052c8b1804e0 OR 4028b204580517120158052c8b0f04de OR 4028b204580517120158052c8b1404df)"
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              },
               {
                "bool": {
                  "should": [
                    {
                      "query_string": {
                        "query": "status:(Yes ) "
                      }
                    },
                    {
                      "query_string": {
                        "query": "status:(No) AND user:(6901)"
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        }
      ],
      "minimum_should_match": 1,
      "filter": [
        {
          "terms": {
            "ACTIVE.keyword": [
              "1"
            ]
          }
        },
        {
          "terms": {
            "FOLDER_ID.keyword": [
              2,
              8,
              9,
              12,
              14,
              -1
            ]
          }
        }
      ]
    }
  },
"highlight": {
        "type" : "unified",
        "fields": {
            "*": {
            }           	 
        }
    }
}

The same query with highlight is taking around 1951ms. This is about more than 45 times than without highlight query.
I want to know the reason behind this delay and Is there a method to optimise the query ?

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