slartidan
slartidan

Reputation: 21586

Do additional date range filters increase the performance?

To an existing, large ElasticSearch 5 index, I want to add a date field, containing the date of the indexation of each document. Afterwards I want to query this index, to return all documents, created in the last minute.

In the ElasticSearch Ultimative Guide for version 1 it is mentioned, that adding additional filters for day, month and/or year can improve the performance drastically. Newer versions of the guide do not say so anymore.

Can I gain performance in ElasticSearch 5 with adding additional date filters?

Upvotes: 5

Views: 210

Answers (1)

Val
Val

Reputation: 217334

Depending on the size of your index, it certainly would help restrain the amount of data that gets considered for your query.

If your index contains years of data, adding a filter to only consider the documents indexed during the last minute will considerably decrease the amount of data that will be focused on for your query.

It was the case with ES 1.x and it is still the case with ES 5.x, the only difference is that in 1.x you had to take care of properly ordering your filters to use the most aggressive filters first, which is not the case anymore in 5.x as ES is now smart enough to run the most aggressive filters first to make sure to weed out unnecessary data very early during the search process.

Upvotes: 4

Related Questions