Search code examples
performanceelasticsearch

Is there a way to turn off scoring when searching in Elasticsearch, to gain performance?


I have over 33 million records in my Elasticsearch 7.1 index and when I query it, I limit the result size to 20. However, ES still scores the records internally. But this isn't important for me and in fact, I want any 20 results. So, for example I don't care if some of the results are more relevant.

My question is, is there a way to turn this behaviour off, and if so, will it improve the performance?


Solution

  • You can use _doc as a sort field. This will make ES return the fields sorted in the order of insertion, and hence it will not do scoring.

    Here is a thread from the forums that explains more: https://discuss.elastic.co/t/most-efficient-way-to-query-without-a-score/57457/4