- Elasticsearch Blueprints
- Vineeth Mohan
- 202字
- 2021-07-16 13:39:33
Filter your results based on a date range
With a fair idea in mind of when to use your filter and when to opt for a query, let's think of some scenarios and see how Elasticsearch enables filtering at its best. Filtering by a date range, prize, or department often pops up in use cases in an e-commerce view. Look at the left-hand side of the following figure:

Checking for new arrivals or selecting an old classic song from a library may need a date-range-based filtering mechanism. Elasticsearch provides inbuilt facilities to do filtering by providing a date range filter. A term filter does the same thing for strings, which can be anything for example, a department or category. A numeric filter filters numerals and can be used for prizes and so on.
This snippet shows how you can implement a date-range-based filtering in Elasticsearch:
{ "query" : { "filtered" : { "query" : { "text" : { "content" : "any keywords to match" } }, "filter" : { "numeric_range" : { "date" : { "lt" : "2011-02-01", "gte" : "2011-01-01" } } } }
These are the parameters taken in a range filter that you may use to specify range offsets:
- R語言數據分析從入門到精通
- 工程軟件開發技術基礎
- 算法基礎:打開程序設計之門
- 機械工程師Python編程:入門、實戰與進階
- Visual C++數字圖像處理技術詳解
- Hands-On Microservices with Kotlin
- QGIS Python Programming Cookbook(Second Edition)
- R語言數據可視化:科技圖表繪制
- C++ System Programming Cookbook
- Maven for Eclipse
- SQL Server on Linux
- Java Script從入門到精通(第5版)
- JavaScript設計模式與開發實踐
- HTML5+CSS+JavaScript深入學習實錄
- 新手學ASP.NET 3.5網絡開發