我为帖子和社区模型建立了索引,
q = Q("multi_match", query=query, fields=['title', 'content'])
document.query(q)
document.aggs.bucket('per_tag', 'terms', field='community')
我想搜索帖子并汇总社区
(返回结果中帖子的社区)
我可能需要使用聚合,实现时遇到了困难,文档对我来说还不清楚。
$link->query($query_items);
答案 0 :(得分:0)
我认为您需要将汇总更改为类似于以下内容的
years = [ Date, Date, Date ]
// This gets date ascending order but not sure how can i remove duplicate
this.years.sort(function(a, b) {
let dateA:any = new Date(a);
let dateB:any = new Date(b);
return (dateA - dateB);
});
console.log( this.years );
因为社区是一个复杂的对象,而elasticsearch只能与简单字段进行聚合。 (关键字或整数)