Elasticsearch在父子关系中排序

时间:2015-09-18 15:15:52

标签: elasticsearch

我在elasticsearch中有一个父子关系,在同一个索引中。而且我想让他们的一个孩子对父母进行排序。在弹性搜索中是否可行。 请帮忙。

示例映射 -

PUT /company

    {
      "mappings": {
        "branch": {},
        "employee": {
          "_parent": {
            "type": "branch" 
          }
        }
      }
    }

样本分支数据

 POST /company/branch/_bulk
{ "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" }

样本员工数据

POST /company/employee/_bulk
{ "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" }

我只想按员工的兴趣按升序排序父母。 请帮我。

0 个答案:

没有答案