1
映射:分支如何在Elasticsearch中搜索具有相同父ID的子文档?
{
"mappings": {
"branch": {},
"employee": {
"_parent": {
"type": "branch"
}
}
}
}
文件:员工
{ "index": { "_id": "london" }}
{ "name": "London Westminster", "city": "London", "country": "UK" }
{ "index": { "_id": "liverpool" }}
{ "name": "Liverpool Central", "city": "Liverpool", "country": "UK" }
{ "index": { "_id": "paris" }}
{ "name": "Champs Élysées", "city": "Paris", "country": "France" }
文件:
{ "index": { "_id": 1, "parent": "london" }}
{ "name": "Alice Smith", "dob": "1970-10-24", "hobby": "hiking" }
{ "index": { "_id": 2, "parent": "london" }}
{ "name": "Mark Thomas", "dob": "1982-05-16", "hobby": "diving" }
{ "index": { "_id": 3, "parent": "liverpool" }}
{ "name": "Barry Smith", "dob": "1979-04-01", "hobby": "hiking" }
{ "index": { "_id": 4, "parent": "paris" }}
{ "name": "Adrien Grand", "dob": "1987-05-11", "hobby": "horses" }
我想找到哪些文件已父ID london
,我想下面的查询:
{
"query":{
"has_parent":{
"type":"branch",
"query":{
"term":{
"_parent":"london"
}
}
}
}
}
但ES返回no results.how在Elasticsearch中搜索具有相同父ID的子文档?
谢谢。它的工作原理。 –
这个问题一直困扰着我的仆人days.Can你帮我吗?@keety http://stackoverflow.com/questions/38886939/add-highlight-does-not-work-with-has-child-query-in -elasticsearch-2-3-3 –
肯定会给它一个镜头 – keety