官术网_书友最值得收藏!

  • Elasticsearch Blueprints
  • Vineeth Mohan
  • 192字
  • 2021-07-16 13:39:33

Implementing a prize range filter

Now, let's move on and see how to implement a prize range filter as seen in some e-commerce websites. Consider the following screenshot of an e-commerce site:

In the preceding screenshot, you can see a price range filter on the left-hand side tab. By clicking on or specifying the price ranges, the products that fall within that range would be displayed. This is nothing but a numeric range filter.

The implementation of a numeric range filter is almost similar to the date range filter in Elasticsearch. The following code snippet shows how to implement a numeric range filter. Here is the sample; assume that you have an age field that is numeric in nature:

{
    "filtered" : {
        "filter" : {
            "range" : {
                "age" : {
                    "gte": 10,
                    "lte": 20
                }
            }
        }
    }
}

After reading the implementation of filters, which is to be followed, you would understand the snippet completely. For time being, we have just showed you how to implement a filter in a numeric field in Elasticsearch.

The same parameters that are shown in the previous table are applied here as well.

主站蜘蛛池模板: 南城县| 濉溪县| 仪征市| 台江县| 收藏| 财经| 赞皇县| 宝鸡市| 霍林郭勒市| 环江| 营山县| 太保市| 揭东县| 积石山| 房产| 绥棱县| 洪江市| 儋州市| 印江| 麦盖提县| 凤阳县| 天津市| 安塞县| 定日县| 梓潼县| 永年县| 静宁县| 南雄市| 乌兰察布市| 阿拉善盟| 香河县| 监利县| 宁蒗| 徐汇区| 巴南区| 花垣县| 确山县| 万盛区| 怀集县| 梅州市| 泰顺县|