i'm creating the mapping in elasticsearch. I have a four objects such as customer, promotion, product and agreement
- Customer - parent and promotion - child(child of customer)
- Promotion - parent and product - child(child of Promotion)
- Promotion - parent and agreement - child(child of Promotion)
i'm creating the mapping in elastic search. I have a four objects such as customer, promotion, product and agreement
- Customer - parent and promotion - child(child of customer)
- Promotion - parent and product - child(child of Promotion)
- Promotion - parent and agreement - child(child of Promotion)
I have created the mapping in the console as shown below for which i need to same using Java API.
PUT /promotionsearch
{
"mappings": {
"properties": {
"customer":{
"properties": {
"id":{
"type": "text"
},
"externalId":{
"type":"text"
},
"businessSystem":{
"type": "integer"
},
"fullName":{
"type":"text"
}
}
},
"promotion":{
"properties": {
"id":{
"type": "text"
},
"externalId":{
"type":"text"
},
"businessSystem":{
"type": "integer"
},
"promotionDescription":{
"type":"text"
},
"promotionType":{
"type":"keyword"
},
"promotionStatus":{
"type":"keyword"
},
"promotionCustomer":{
"type":"text"
},
"promotionProducts":{
"type":"nested"
}
}
},
"product":{
"properties": {
"id":{
"type":"text"
},
"externalId":{
"type":"text"
},
"businessSystem":{
"type":"integer"
},
"productDescription":{
"type":"text"
}
}
},
"rebateagreement":{
"properties": {
"id":{
"type":"text"
},
"businessSystem":{
"type":"integer"
},
"validFrom":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"validTo":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
},
"promotion_search_join":{
"type": "join",
"relations":{
"customer":"promotion",
"promotion":["product", "rebate"]
}
}
}
}
}
My question is if you see the Promotion mapping, it has field promotionProducts which is actually a list which contains the product. So i have made it as Type Nested .
- Is it valid to have a nested objects like in parent-child relations?
- Does this adds more complexity while querying?
I did explored the document of ES, could find anything related to this scenario. Any help would be appreciated.