0

我在 Elasticsearch 中索引了一个子文档,如下所示:

{
 _parent: chow-demo
 _index: prototype_2013.01.02
 _type: chow-clfg
 _id: l7jvEgD-SrG-Ws_9ab52IA
 _score: 11.600378
 _source: {
  chow-clfg: {
  @type: chow-clfg
  clfg: Cg5iUlAvU9IIAAAA8Rg
  @timestamp: 2013-01-02T10:15:00.000Z
  count: 1
  }
 }
}

父级至少有 2 条记录具有clfg作为通用标识符,如下所示:

{
 _index: "prototype_2013.01.02",
 _type: chow-demo, 
 clfg: Cg5iUlAvU9IIAAAA8Rg,
 obid: 97066795
}

但是,当我使用“has_child”查询时,我没有得到任何结果:

curl -XGET "localhost:9200:/prototype_2013.01.02/chow-demo/_search"
{
 "query": {
  "has_child": {
   "type": "chow-clfg",
   "query": {
    "term": {
      "clfg": "Cg5iUlAvU9IIAAAA8Rg"
    }
   }
  }
 }
}

但是,当我单独查询文档时,返回了正确的结果。为什么呢?父路由是否应该能够使用父字段使用子路由来识别结果?

4

1 回答 1

0

当孩子被索引时,它的“_parent”字段应该包含父母的id(不是父母的类型,因为它似乎是你的情况)。

于 2013-01-02T11:16:05.630 回答