ElasticSearch学习
ElasticSearch学习
分组:
按series_name字段分组取前几条数据:
{ "query": { "bool": { "filter": [ { "range": { "request_time": { "gt": "2019-07-03", "lt": "2019-07-05" } } }, { "bool": { "must": [ { "match_phrase": { "province_code": { "query": "00644" } } } ] } } ] } }, "aggs": { "group_by_series_name": { "terms": { "field": "series_name.keyword", "size": 5, "order": { "_count": "desc" } } } }, "size": 0 }
match_all: 全部查询
GET dw_app_car_offering_price_ds/_search { "query": { "match_all": {} } }
单个查询
GET dw_app_car_offering_price_ds/_search { "query": { "term": { "model_code": { "value": "12550-n" } } } }
size:默认10条
GET dw_app_car_offering_price_ds/_search { "query": { "term": { "model_code": { "value": "12550-n" } } }, "size": 20 }
from size :从某个from索引的size条数据
GET dw_app_car_offering_price_ds/_search { "query": { "term": { "source": { "value": "che168" } } }, "from": 10, "size": 10 }
sort :排序
GET dw_app_car_offering_price_ds/_search { "query": { "bool": { "must": [ { "term": { "model_code": { "value": "201795" } } }, { "term": { "source": { "value": "che168" } } }, { "term": { "city_code": { "value": "00002" } } } ] } }, "size": 100, "sort": [ { "ds": { "order": "desc" } } ] }
_source:条件查询
GET dw_app_car_offering_price_ds/_search { "query": { "term": { "model_code": { "value": "12550-n" } } }, "_source": ["offering_price_50","city_code"] }
参考:https://www.cnblogs.com/pilihaotian/p/5830754.html
2.0的语法: