java api查询我是这个使用的,现在查出来的结果数据过程如下:
TermsBuilder teamAgg= AggregationBuilders.terms("agg").field("person_id") .subAggregation( AggregationBuilders.topHits("top") .setFrom((params.getPageNo()-1)*params.getPageRows()).setSize(params.getPageRows()) ).minDocCount(Long.valueOf(1)) .size(Integer.valueOf(10));
Terms agg = response.getAggregations().get("agg");
for (Terms.Bucket entry : agg.getBuckets()) {
TopHits topHits = entry.getAggregations().get("top");
}
topHits 中数据根据时间字段排序该怎么排,目前是散乱的
TermsBuilder teamAgg= AggregationBuilders.terms("agg").field("person_id") .subAggregation( AggregationBuilders.topHits("top") .setFrom((params.getPageNo()-1)*params.getPageRows()).setSize(params.getPageRows()) ).minDocCount(Long.valueOf(1)) .size(Integer.valueOf(10));
Terms agg = response.getAggregations().get("agg");
for (Terms.Bucket entry : agg.getBuckets()) {
TopHits topHits = entry.getAggregations().get("top");
}
topHits 中数据根据时间字段排序该怎么排,目前是散乱的
5 个回复
laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net
赞同来自: zyb1994111
张鹏
赞同来自:
"query" : {
"bool" : {
"must" : [ {
"range" : {
"fcap_time" : {
"from" : 1528300800,
"to" : 1528387200,
"include_lower" : true,
"include_upper" : true
}
}
}, {
"bool" : {
"should" : {
"terms" : {
"fcap_dcid" : [ "f94bc77ef21e4c8bad38c8400e854c8b" ]
}
}
}
} ]
}
},
"explain" : true,
"sort" : [ {
"fcap_dcid" : {
"order" : "desc"
}
} ],
"aggregations" : {
"agg" : {
"terms" : {
"field" : "person_id",
"size" : 100,
"order" : {
"_term" : "desc"
}
},
"aggregations" : {
"top" : {
"top_hits" : {
"size" : 1,
"sort" : [ {
"fcap_time" : {
"order" : "desc"
}
} ]
}
},
"agg" : {
"terms" : {
"field" : "fcap_time",
"order" : {
"_term" : "desc"
}
}
}
}
}
}
}
张鹏
赞同来自:
wssmao
赞同来自:
johnsontang
赞同来自: