Below is the JSON I have
`[
{
“item_attr1”: “abc”,
“item_attr2”: “123”,
“item_attr3”: “123”,
“item_id”: “12345”,
“bucket_attr1”: 1919,
“bucket_attr2”: “abc”,
“bucket_attr3”: 1922,
“bucket_attr4”: “abc”,
“bucket_id_1”: “abc”,
“bucket_id_2”: “def”,
“bucket_id_3”: “ghi”,
“articleattribute1”: “abc”,
“articleattribute2”: “abc”,
“articleattribute3”: “2233”,
“article_id”: “12345”
},
{
“item_attr1”: “abc”,
“item_attr2”: “123”,
“item_attr3”: “123”,
“item_id”: “543421”,
“bucket_attr1”: 1919,
“bucket_attr2”: “abc”,
“bucket_attr3”: 1922,
“bucket_attr4”: “abc”,
“bucket_id_1”: “abc”,
“bucket_id_2”: “mef”,
“articleattribute1”: “abc”,
“articleattribute2”: “abc”,
“articleattribute3”: “2233”,
“article_id”: “12345”
}
]
`
I need to group by bucket_id_1, bucket_id_2 and bucket_id_3 and then group that result by article_id so that that the output may look like
`{
“buckets”: [
{
“bucket_id”: “abc”,
“bucket_attr1”: 1919,
“bucket_attr2”: “abc”,
“bucket_attr3”: 1922,
“bucket_attr4”: “abc”,
“articles”: [
{
“articleattribute1”: “abc”,
“articleattribute2”: “abc”,
“articleattribute3”: “2233”,
“article_id”: “12345”,
“items”: [
{
“item_attr1”: “abc”,
“item_attr2”: “123”,
“item_attr3”: “123”,
“item_id”: “12345”
},
{
“item_attr1”: “abc”,
“item_attr2”: “123”,
“item_attr3”: “123”,
“item_id”: “543421”
}
]
}
]
}
]
}
`
I tried to write Jolt transformation and shiftr operations and also used below site for validating my transformation but could not get the result in my expected format
Shashi Kiran GM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.