DSL 语句:
GET /idx_sku_statistics_index/sku_index/_search
{
"from" : 0,
"size" : 100,
"query" : {
"bool" : {
"must":[
{
"range" : {
"salePrice" : {
"from" : 1.9,
"to" : 2.1,
"include_lower": true,
"include_upper": true
}
}
}
,
{
"bool": {
"must": {
"term": {
"cityId": 136
}
}
}
}
]
}
},
"sort": [
{
"salePrice": "asc"
}
]
}
解释说:
range: 表示范围查询;
salePrice: 针对salePrice字段做范围查询;
include_lower 做>= 查询还是 > 查询; true 就是 >=
include_upper 做<= 查询还是 < 查询; true 就是 <=
sort 表示排序数组: 可以根据多个字段字段; 当前是根据salePrice 做顺序排序
本文详细解析了一段DSL语句,该语句用于在Elasticsearch中执行范围查询和按特定字段排序。通过`range`关键字,实现了针对`salePrice`字段的大于等于1.9且小于等于2.1的价格筛选。`include_lower`和`include_upper`分别控制了范围边界是否包含。同时,结合`bool`查询,对`cityId`为136的记录进行过滤。最后,使用`sort`数组对结果进行升序排序。这段DSL语句展示了Elasticsearch高级查询和数据过滤的能力。
1万+

被折叠的 条评论
为什么被折叠?



