How to insert the following JSON nested array abject into Elasticsearch index named "index_19_7_16"
?
{
"hour": [
{
"time": "00:00",
"master_id": [
{
"m.id": 111,
"m.value": 222
},
{
"m.id": 113,
"m.value": 444
}
],
"child_id": [
{
"c.id": 77,
"c.value": 222
},
{
"c.id": 7751,
"c.value": 444
}
]
},
{
"time": "01:00",
"master_id": [
{
"m.id": 111,
"m.value": 222
},
{
"m.id": 113,
"m.value": 444
}
],
"child_id": [
{
"c.id": 77,
"c.value": 222
},
{
"c.id": 7751,
"c.value": 444
}
]
}
]
}
Do I need to created mapping before or just insert the JSON dynamically into elastic index.
You need to create the mapping upfront and specifically mention that some fields have to be "type":"nested"
otherwise ES will just create objects. Here I specifically refer to nested type of fields in ES.
If by nested you meant just the nested nature of the document, then you don't have to do anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With