Elasticsearch JavaAPI支持AggregationBuilder的总和,最小值,最大值,平均数和计数。那么First / First_value和Last / Last_value怎么实现这些功能。
这里是对文档https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_metrics_aggregations.html
的引用答案 0 :(得分:0)
您可以在Elasticsearch查询中使用聚合器
"aggs": {
"FIRST_VALUE": {
"top_hits": {
"size": 1,
"sort": [
{
//The string below measures or assess which among the column would you like to arrange in order,
//for this example, we presume that there's a "my_date" field in your index
"my_date": {
"order": "asc"
}
}
]
}
},
"LAST_VALUE": {
"top_hits": {
"size": 1,
"sort": [
{
"my_date": {
"order": "desc"
}
}
]
}
}
}