Elastic Search Sorting takes time between 4-5 secs


(Nikhil Bansal) #1

Hi,

We have implemented Elastic search and have changed some of our mappings,but the results after we added some more mapping fields are not so good.We are sorting the result in desc order based on time which is of type long.The search query returns the results within milliseconds but when we add sort parameter in CURL query the result returned is taking more than 5 secs.

Before changing the mappings the results were good,but after adding few more mappings the results are poor.
Can anybody help us out in this.


(Colin Goodheart-Smithe) #2

I'm going to change the category for this topic to 'Elasticsearch' as the topic is not about Elastic User Groups. You will find more help on this topic there


(Harlin) #3

Sorting in elasticsearch is pretty slow by defualt. This is because it involves uninverting the inverted indices in Lucene in order to pull out the field data to get sorted, on your case the timestamps. One way to solve this if memory isn't an issue is to eagerly load the field data:

https://www.elastic.co/guide/en/elasticsearch/guide/current/preload-fielddata.html

Another way is to use doc values. Using doc values will store all of this field data separately from the Lucene indices so it is more accessible. Read more here:

https://www.elastic.co/guide/en/elasticsearch/guide/current/doc-values.html


(system) #4