我想获得排名前10位的文档\行,这些行应该最近订购这些行,并且最多可以访问多次文档。
“{\”size \“:10,\”query \“:{\”range \“:{\”searchDate \“:{\”gte \“:\”“+ DateTime.Now.AddDays( -30)+“\”},\“aggs \”:{\“top_tags \”:{\“terms \”:{\“field \”:\“searchDate \”},\“aggs \”:{ \“top_otf_hits \”:{\“top_hits \”:{\“sort \”:[{\“saerchDate \”:{\“order \”:\“desc \”}}],\“_ source \”: {\“includes \”:[\“origin \”,\“destination \”]},\“size \”:1}}}}}}}}“
答案 0 :(得分:1)
{
"from": 0,
"size": 0,
"sort": [{
"searchDate": "desc"
}, "_score"],
"query": {
"range": {
"searchDate": {
"gte": "2018-02-28",
"lte": "2018-03-05",
"format": "yyyy-MM-dd"
}
}
},
"aggs": {
"frequent": {
"terms": {
"field": "tripKey"
},
"aggs": {
"top_otf_hits": {
"top_hits": {
"sort": [{
"searchDate": {
"order": "desc"
}
}],
"_source": {
"include": ["*"]
},
"size": 1
}
}
}
}
}
}