0
所以,我根據這個設定我Elasticsearch店:https://www.elastic.co/guide/en/elasticsearch/guide/current/grandparents.html如何查詢針對祖父母inner_hits在多代設置
PUT /company
{
"mappings": {
"country": {},
"branch": {
"_parent": {
"type": "country"
}
},
"employee": {
"_parent": {
"type": "branch"
}
}
}
}
POST /company/country/_bulk
{ "index": { "_id": "uk" }}
{ "name": "UK" }
{ "index": { "_id": "france" }}
{ "name": "France" }
POST /company/branch/_bulk
{ "index": { "_id": "london", "parent": "uk" }}
{ "name": "London Westmintster" }
{ "index": { "_id": "liverpool", "parent": "uk" }}
{ "name": "Liverpool Central" }
{ "index": { "_id": "paris", "parent": "france" }}
{ "name": "Champs Élysées" }
PUT /company/employee/1?parent=london&routing=uk
{
"name": "Alice Smith",
"dob": "1970-10-24",
"hobby": "hiking"
}
此查詢工作正常和預期收益愛麗絲,但沒有inner_hits:
POST /company/employee/_search
{
"query": {
"has_parent": {
"type": "branch",
"query": {
"term": {"_id": "london"}
},
"inner_hits": {}
}
}
}
但此查詢不返回任何inner_hits:
POST /company/employee/_search
{
"query": {
"has_parent": {
"type": "branch",
"query": {
"has_parent": {
"type": "country",
"query": {
"term": {"_id": "uk"}
}
},
"inner_hits": {}
}
}
}
}
我認爲它會返回Alice,但它不會。我如何找到所有國家爲uk
的員工?
請注意,elastic.co上的示例查詢也不返回任何inner_hits。以下是查詢:
GET /company/country/_search
{
"query": {
"has_child": {
"type": "branch",
"query": {
"has_child": {
"type": "employee",
"query": {
"match": {
"hobby": "hiking"
}
},
"inner_hits": {}
}
}
}
}
}
我得到零個inner_hits。