DSL语句
GET /idx_hippo_sku_statistics_index/sku_statistics_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" } ], "_source": ["productName","salePrice"] }
"_source": ["productName","salePrice"] 表示查询的结果集只返回 这里面的字段;
"sort": [ { "salePrice": "asc" } ], 表示根据salePrice 字段做升序排序;
"range" : { "salePrice" : { "from" : 1.9, "to" : 2.1, "include_lower": true, "include_upper": true } }
根据 salePrice 查询在>= 1.9 ,小于等于2.1 的数据;
include_lower 为true 表示 >=
include_upper 为true 表示<=
term 查询,类似mysql = 查询;