如何在elasticsearch中聚合子-父母-孩子

时间:2018-07-30 09:29:28

标签: elasticsearch parent-child elasticsearch-aggregation

我的映射如下:

{ "a": {
  "properties": {
    "id": {
      "type": "integer"
    },
    "name_1":{
      "type":"keyword"
    }
  }
},
{ "b": {
  "properties": {
    "id": {
      "type": "integer"
    },
    "a_id": {
      "type": "integer"
    },
    "name_2":{
      "type":"keyword"
    }
   },
  "_parent": {
    "type": "a"
  }
}, 
{ "c": {
    "properties": {
      "id": {
        "type": "integer"
      },
      "a_id": {
        "type": "integer"
      },
      "name_3":{
        "type":"keyword"
      }
    },
    "_parent": {
      "type": "a"
    }
  }
}

其中a.id = b.a_id,c.a_id。 a和b 之间有很多关系, 在 a和c

之间一对多

现在我想基于字段name_2汇总数据以列出所有name_3和doc_count

0 个答案:

没有答案