parent/child relationship didn't work in ElasticSearch

蓝咒 提交于 2021-02-10 04:44:08

问题


how can I use parent/child relationship in ElasticSearch-7

all my documents have _doc type

I want to implement something like the one shown below

// index = `order_item`
{
    "ID": 1,
    "Name": "Shoes",
    "Price": 9.99,
    "OrderID": 82
},
{
    "ID": 2,
    "Name": "Hat",
    "Price": 19.99,
    "OrderID": 82
}

// index = `order`
{
    "ID": 82,
    "Customer": "John Smith"
}

I want join these indices as below with parent/child relationship

order
{
   "ID": 82,
   "Customer": "John Smith",
   "order-item": [
      {
        "ID": 1,
        "Name": "Shoes",
        "Price": 9.99,
       },
       { 
        "ID": 2,
        "Name": "Hat",
        "Price": 19.99,
       }
     ]
}

or for each order_item

order-item
{
   "ID": 2,
   "Name": "Hat",
   "Price": 19.99,
   "Order": {
        "ID": 82,
        "Customer": "John Smith"
     }
       
}

来源:https://stackoverflow.com/questions/66098816/parent-child-relationship-didnt-work-in-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!