From the course: Elasticsearch Essential Training

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Handling dates in Elasticsearch

Handling dates in Elasticsearch - Elastic Stack Tutorial

From the course: Elasticsearch Essential Training

Handling dates in Elasticsearch

- [Instructor] Assume that you are building a reporting dashboard and need to fetch orders from last 30 days, or maybe you wanted to show top selling product of this year. Handling dates is essential in Elasticsearch, whether you are dealing with the sales data, user activity, or the system log. Date is something an important attribute to take care of, so let's just see how we can play with the dates into an Elasticsearch. Let's just see our orders index. In that order index documents, you can find that we have a one attribute called order_date. Now, this attribute is having of type date. Now, imagine that you wanted to bring in all the orders which has been punched in last 30 days. Is it possible to do it? Yes. For that, we're going to use this specific query, which I have copied from the exercise file. In this query, you can see that I'm saying that find out all the orders which has the date greater than the last 30 days and less than equal to today's date. And let me execute this…

Contents