Hello everyone,
I'm starting with Elasticsearch and I have created a simple one node cluster to explore its capabilities. At the moment I have been trying to put data into elasticsearch with nested json objects. I have read through documentation and several other links but I think I'm missing something here.
My goal is to have Network property with accessible sub properties i.e. Network[0].Adapter_Type however I cannot get this to work.
I'm posting into elasticsearch json which looks following :
{
"ESXI_Name": "stewie.prd.local",
"VM_Name": "asterix-01",
"VM_Datastore_Name": [
"xyz-2",
"xyz-2",
],
"VM_vCPUs": 2,
"VM_MemoryGB": 16,
"Guest_OS": "Microsoft Windows Server 2008 R2 (64-bit)",
"Network": [
{
"VM_Name": "asterix-01",
"Adapter_Name": "Network adapter 2",
"Adapter_Type": "Vmxnet3",
"PortGroup": "vlan-666",
"Adapter_MacAddress": "00:FF:56:AF:01:05",
"Adapter_WakeOnLan": true
},
{
"VM_Name": "asterix-01",
"Adapter_Name": "Network adapter 2",
"Adapter_Type": "Vmxnet3",
"PortGroup": "vlan-666",
"Adapter_MacAddress": "00:FF:4A:87:01:05",
"Adapter_WakeOnLan": true
}
],
"datetime": "20160325T143803Z"
}
I'm sending this to index cmdb with type of server. From what I found in documentation is that I would need to create a mapping - which I have done using the following :
{
"mappings": {
"server": {
"properties": {
"Network": {
"type": "nested",
"properties": {
"VM_Name": { "type": "string" },
"Adapter_Name": { "type": "string" },
"Adapter_Type": { "type": "string" },
"PortGroup": { "type": "string" },
"Adapter_MacAddress": { "type": "string" },
"Adapter_WakeOnLan": { "type": "string" }
}
}
}
}
}
}
But as soon as I post any data I get Network contents as JSON i.e.
{
"VM_Name": "asterix-01",
"Adapter_Name": "Network adapter 2",
"Adapter_Type": "Vmxnet3",
"PortGroup": "vlan-666",
"Adapter_MacAddress": "00:FF:56:87:01:05",
"Adapter_WakeOnLan": true
},
{
"VM_Name": "asterix-01",
"Adapter_Name": "Network adapter 2",
"Adapter_Type": "Vmxnet3",
"PortGroup": "vlan-666",
"Adapter_MacAddress": "00:50:AA:87:D5:05",
"Adapter_WakeOnLan": true
}
If anyone could point me into direction how I could get this properly sorted would be great!
thanks
Raf