Es怎么实现按多字段去重查询呢?不是统计,是查询结果,按多字段分组每组显示一条;
试了下collapse的折叠功能很好用,但只能折叠一个字段,
script_fields合并的字段又不能在collapse中使用,提示:
 
 
大家有没有什么好办法实现多字段去重查询呢?
 
															
																				试了下collapse的折叠功能很好用,但只能折叠一个字段,
script_fields合并的字段又不能在collapse中使用,提示:
"caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "no mapping found for `group_field` in order to collapse on",
      "caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "no mapping found for `group_field` in order to collapse on"
      }
    }
大家有没有什么好办法实现多字段去重查询呢?

 
	
3 个回复
God_lockin
赞同来自:
zhangcm - 90后
赞同来自:
{
"explain": false,
"size": 0,
"aggs": {
"my-agg-name": {
"terms": {
"field": "authorId"
},
"aggs": {
"book_id": {
"terms": {
"size": 1,
"field": "bookId",
"order": {
"_key": "desc"
}
}
}
}
},
"aggs": {
"other_field_xxx": {
"terms": {
"size": 1,
"field": "other_field_xxx",
"order": {
"_key": "desc"
}
}
}
}
}
}
}
charlesfang
赞同来自:
https://www.elastic.co/guide/e ... psing