Is it better to have a data redundancy with single nested object or maintain multilevel nested document?
There are performance concerns when nested types are used, as per elasticsearch documentation Nested field type | Elasticsearch Guide [7.13] | Elastic
In the below data Scenario#1-> lineLevelDetails (single level nested)captures line, shipment and carton information.
Scenario#2-> Shipment(nested) and carton (nested) details are multi-level nested.
Can experts suggest which scenario is a better option?
Also, updates are expected for lineleveldetails, shipment and cartons data.
Scenario#1:
{
"orderLocation": "xyz",
"orderStatusCode": "6",
"orderId": "2214828263 ",
"lineLevelDetails": [
{
"lineId": "1",
"shipmentId": "1",
"lineStatusCode": "3",
"shipmentStatusCode": "3",
"shipmentStatusDesc": "",
"deliveryStatus": "",
"deliveryStatusTs": "",
"deliveryTrackingNumber": "",
"cartonNumber": 1234
},
{
"lineId": "2",
"shipmentId": "1",
"lineStatusCode": "3",
"shipmentStatusCode": "3",
"shipmentStatusDesc": "",
"deliveryStatus": "",
"deliveryStatusTs": "",
"deliveryTrackingNumber": "",
"cartonNumber": 4567
},
{
"lineId": "3",
"shipmentId": "1",
"lineStatusCode": "3",
"shipmentStatusCode": "3",
"shipmentStatusDesc": "",
"deliveryStatus": "",
"deliveryStatusTs": "",
"deliveryTrackingNumber": "",
"cartonNumber": 3333
}
]
}
Scenario#2:
{
"orderLocation": "xyz",
"orderStatusCode": "6",
"orderId": "2214828263 ",
"lineLevelDetails": [
{
"lineId": "1",
"lineStatusCode": "3"
},
{
"lineId": "2",
"lineStatusCode": "3"
},
{
"lineId": "3",
"lineStatusCode": "3",
}
],
"shipment": [ {
"shipmentId": "1",
"shipmentStatusCode": "3",
"shipmentStatusDesc": "",
"deliveryStatus": "",
"deliveryStatusTs": "",
"deliveryTrackingNumber": "",
"cartons":[ {
"lineId": 1,
"cartonNumber": 1234
},{
"lineId": 2,
"cartonNumber": 4567
}]
},
{
"shipmentId": "2",
"shipmentStatusCode": "4",
"shipmentStatusDesc": "",
"deliveryStatus": "",
"deliveryStatusTs": "",
"deliveryTrackingNumber": "",
"lines":[ {
"lineId": 3,
"cartonNumber": 3333
}]
},
}]
}