Hi,
I'm pretty sure I need to use ruby to achive this but I don't really know anything about it.
I've done a translation with logstash already where I enrich an ID field that occurs once per document. What I need to do now though is add a name supplier to a nested array of data that could contain 1 or many repeating entries.
For example:
"customerID" : 123456,
"customerName": "John smith",
"Orders" : [
{
"orderId" : "123456",
"dateTimeOrdered" : "2019-02-01T00:07:39Z",
"orderedItems" : [
{
"objectType" : 0,
"productId" : 1536
},
{
"objectType" : 0,
"productId" : 1529
},
{
"objectType" : 0,
"productId" : 1490
},
{
"objectType" : 0,
"productId" : 1535
}
]
}
]
And using translation filter with records that look like
'1536' : '{"name": "red ball", "supplier" : "Fred"}'
'1529' : '{"name" : "yellow rocket","supplier": "Steve"},
'1490' : '{"name" : "fire truck","supplier" : "Jim Bob"}'
'1535# : '{"name" : "squad car", "supplier" : "Jim Bob"}'
Get logstash to use an elasticsearch pulgin to collect that data, a tranlation filter using the above dictionary file to loop through each of the orders and then use the elasticserach output pluging to update the docuemtent to look like.
"customerID" : 123456,
"customerName": "John smith",
"Orders" : [
{
"orderId" : "123456",
"dateTimeOrdered" : "2019-02-01T00:07:39Z",
"orderedItems" : [
{
"objectType" : 0,
"productId" : 1536,
"name" : "red ball",
"supplier" : "Fred"
},
{
"objectType" : 0,
"productId" : 1529,
"name" : "yellow rocket",
"supplier": "Steve"
},
{
"objectType" : 0,
"productId" : 1490,
"name" : "fire truck",
"supplier" : "Jim Bob"
},
{
"objectType" : 0,
"productId" : 1535,
"name" : "squad car"
"supplier" : "Jim Bob"
}
]
}
]
There would be other fields in the docuement but I've omited them for the sake of brevity.
I feel ruby comes into this somewhere but I don't know enough about it to understand where to start with it to make headway on this.
Many thanks for your help in advance
Kind regards
Ant