普通查询,多条件查询
must term 类似数据库 =
must terms 类似于数据库查询的 in
must_not term 类型数据库的 !=
must_not terms 类型于数据库查询的 not in
POST /exp-order-v1-benchmark-202010/_search{"query": {"bool": {"must": [{"terms": {"orderStatus": [4, 5]}},{ "term": { "billId": { "value": "1146949448946155522" } }}],"filter": { "term": { "orderType": "1" }}}}} POST /exp-order-v1-benchmark-202010/_search{"query": {"bool": {"must": [{"terms": {"orderStatus": [4, 5]}},{ "term": { "billId": { "value": "1146949448946155522" } }}],"filter": { "term": { "orderType": "9" }}, "must_not": [ { "term": { "orderStatus": { "value": "4" } } } ]}}}
count查询条数
range里是范围查询
POST /exp-order-v1-benchmark-202010/_count{ "query": { "range": { "billCreateTime": { "gte": 1603814409000, "lte": 1603900809000 } } }}
group by ,根据billSenderCityId字段进行分组,可以查询获取到每个桶的个数
POST /exp-order-v1-benchmark-202010/_search{"query": {"range": {"billCreateTime": {"gte": 1603814409000,"lte": 1603900809000}}},"size": 0,"aggregations": {"field1": {"terms": {"field": "billSenderCityId","size": 20}}}}
类似于count(distinct(billSenderCityId)),可以获取到去重后的billSenderCityId的个数
POST /exp-order-v1-benchmark-202010/_search
{ "query": { "range": { "billCreateTime": { "gte": 1603814409000, "lte": 1603900809000 } } }, "aggs": { "field": { "cardinality": { "field": "billSenderCityId" } } }, "size": 0}