@vsr1 Iam strugling with a query and I could not figure out what I am doing wrong.
I have a few documents , which I would like to query by the key:
the document format is this:
{
"chart_timestamp": 1597590000,
"chart_apps": {
"aaa": 270,
"bbb": 357,
"ccc": 451,
"ddd": 93
},
"version": 1
}
I have multiple documents like this, but with different object (chart_apps) keys (some keys will repeat on other documents for example here (“bbb” and “ddd”):
{
"chart_timestamp": 1597590000,
"chart_apps": {
"eee": 270,
"bbb": 3,
"fff": 451,
"ddd": 76
},
"version": 1
}
Another example:
{
"chart_timestamp": 1597590000,
"chart_apps": {
"aaa": 14,
"bbb":9,
"fff": 32,
"ccc": 778
},
"version": 1
}
Now, what I need is to be able to join multiple documents based on their keys and generate a response like this:
{
"foo":{
"aaa":{
"first_join":270, // value_from_frist_document
"second_join": null, //value_from_the_second_document
"third_join": 14 //value_from_the_third_document
}
},
"bbb":{
"first_join":357, // value_from_frist_document
"second_join":3, //value_from_the_second_document
"third_join":9 //value_from_the_third_document
}
},
"ccc":{
"first_join": 451 , // value_from_frist_document
"second_join": null, //value_from_the_second_document
"third_join": 778 //value_from_the_third_document
}
},
"ddd":{
"first_join":93, // value_from_frist_document
"second_join": 76, //value_from_the_second_document
"third_join":null //value_from_the_third_document
}
},
"eee":{
"first_join":null, // value_from_frist_document
"second_join":270, //value_from_the_second_document
"third_join":null //value_from_the_third_document
}
},
"fff":{
"first_join": null, // value_from_frist_document
"second_join": 451, //value_from_the_second_document
"third_join":32 //value_from_the_third_document
}
}
}
some of the joined documents may not have that key/value and I need to have all the keys from all the documents in the new resulting object and for the missing value I can have null.
Is there a way to do this?