简体   繁体   English

无法使用Elasticsearch搜索父文档和子文档?

[英]Unable to search for parent and child documents using Elasticsearch?

I have indexed a child document in Elasticsearch as follows: 我已经在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
  }
 }
}

The parent has at least 2 records that has clfg as a common identifier as follows: 父级至少有2条具有clfg作为通用标识符的记录,如下所示:

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

However when I query using the "has_child" query, I get no results: 但是,当我使用“ has_child”查询进行查询时,没有任何结果:

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

However when I query individually for the documents, there were correct results returned. 但是,当我单独查询文档时,返回了正确的结果。 Why is that so? 为什么会这样? Isn't the parent routing supposed to be able to identify results using the child using the parent field? 父级路由是否应该能够使用父级字段使用子级识别结果?

为子级编制索引时,其“ _parent”字段应包含父级的ID(而不是父级的类型,因为您的情况似乎如此)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Elasticsearch.Net/NEST基于子属性搜索父文档,其中父/子文档单独存储 - Using Elasticsearch.Net/NEST to search parent documents based on child attributes, where parent/child documents are stored separately Elasticsearch 搜索孩子及其所有按父母分组的兄弟文件 - Elasticsearch search for a child and all his sibling documents grouped by parent 如何在Elasticsearch中搜索具有相同父ID的子文档? - how to search child documents with the same parent id in Elasticsearch? 带有父子文档的弹性搜索问题 - problems on elasticsearch with parent child documents 使用 Jest 在 Elasticsearch 中删除没有父级的子文档 - Delete child documents without parent in Elasticsearch using Jest 如何在ver_6.2.4的Elasticsearch中搜索具有相同父ID的子文档? - how to search child documents with the same parent id in Elasticsearch on ver_6.2.4? 如何在Elasticsearch 6.2.1版中使用Java API索引父文档和子文档 - How to index parent and child documents using java API in Elasticsearch version 6.2.1 Elasticsearch - 获取子文档(获取已命中子文档的父文档) - Elasticsearch - get child documents of (get parent documents which has hit in child documents) 关于 Elasticsearch 的多父子搜索 - The multiple Parent-child search about Elasticsearch Elasticsearch父级-子级映射:同时搜索并突出显示 - Elasticsearch parent - child mapping: Search in both and highlight
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM