[英]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.