- _source 数组 指定返回字段
- collapse 折叠,类似mysql 的distinct 功能。
- 一次查询即可以按条件查询出所有的数据,也可以查出聚合统计的数据
GET es_clue_index/_search
{
"size": 10000,
"query": {
"bool": {
"must": [{
"term": {
"distStatus": {
"value": "1",
"boost": 1.0
}
}
}],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"_source": {
"includes": ["companyName", "companyId", "followId", "followName"],
"excludes": []
},
"aggregations": {
"busi": {
"terms": {
"field": "followId",
"size": 10,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [{
"_count": "desc"
}, {
"_key": "asc"
}]
},
"aggregations": {
"lastDistTime": {
"date_range": {
"field": "lastDistTime",
"ranges": [{
"from": "2019-12-28 00:00:00",
"to": "2019-12-29 00:00:00"
}],
"keyed": false
}
},
"lastFollowTime": {
"date_range": {
"field": "lastFollowTime",
"ranges": [{
"from": "2019-12-28 00:00:00",
"to": "2019-12-29 00:00:00"
}],
"keyed": false
}
},
"clueBeOrderTime": {
"date_range": {
"field": "lastFollowTime",
"ranges": [{
"from": "2019-12-28 00:00:00",
"to": "2019-12-29 00:00:00"
}],
"keyed": false
}
},
"followStatus": {
"range": {
"field": "followStatus",
"ranges": [{
"key": "closedClue",
"from": 3.0,
"to": 4.0
}, {
"key": "checkoutOrder",
"from": 2.0,
"to": 3.0
}, {
"key": "toBeFollowed",
"from": 1.0,
"to": 3.0
}],
"keyed": false
}
}
}
}
},
"collapse": {
"field": "followId"
}
}