我想知道如何在elasticsearch中投影aggs查询中的所有字段。假设我有这样的数据集:
{
sent_id: 1
doc_id: 5
text: "test1"
year: "2015"
}
{
sent_id: 2
doc_id: 5
text: "test2"
year: "2015"
}
我想根据我的doc_id为所有有特定标准的句子做一个分组。我想要这样的结果:
doc_id:5
{
{sent_id:1, year:2015, text: "test1"},
{sent_id:2, year:2015, text: "test2"},
etc
},
doc_id: xx
{
{sent_id:xx, year:2015, text: "xx"}
}
下面给了我或多或少我想要的东西,除了它没有投影所有其他领域。
"query": {
"query_string": {
"fields": ["text"],
"query" : "affordable energy"}}
,"size": 0
,"aggs":{
"doc_id":{
"terms": {
"field": "doc_id"
,"size": 0
},
"aggs": {
"sents_info": {
"terms": {
"field": "sent_id",
"size": 0
}
}
}
}
}
发布于 2016-08-02 03:06:32
"aggs": {
"doc_id": {
"terms": {
"field": "doc_id",
"size": 0
},
"aggs": {
"sents_info": {
"terms": {
"field": "sent_id",
"size": 0
},
"aggs": {
"top10": {
"top_hits": {
"size": 10
}
}
}
}
}
}
}
https://stackoverflow.com/questions/38696407
复制相似问题