Hi All! I’ve got a doozy… I need to reduce some data from a large collection. The data I am focusing on looks like this:
[
{
"HistogramData": {
"HistogramDataColumnTitle": {
"ColumnTitle": [
"Tran PPV in/s",
"Tran Freq Hz",
"Vert PPV in/s",
"Vert Freq Hz",
"Long PPV in/s",
"Long Freq Hz",
"Geophone PVS in/s"
]
},
"HistogramDataIntervals": {
"Time": "2021-05-20 12:22:32",
"Row": {
"Cell": [
"0.1462",
"46.5",
"0.0525",
">100",
"0.5494",
"25.6",
"0.5577"
]
}
}
}
},
{
"HistogramData": {
"HistogramDataColumnTitle": {
"ColumnTitle": [
"Tran PPV in/s",
"Tran Freq Hz",
"Vert PPV in/s",
"Vert Freq Hz",
"Long PPV in/s",
"Long Freq Hz",
"Geophone PVS in/s"
]
},
"HistogramDataIntervals": [
{
"Time": "2021-05-22 19:15:51",
"Row": {
"Cell": [
"0.0050",
"19.7",
"0.0056",
"7.4",
"0.0050",
"28.4",
"0.0063"
]
}
},
{
"Time": "2021-05-22 19:30:51",
"Row": {
"Cell": [
"0.0050",
"60.2",
"0.0044",
"20.5",
"0.0050",
"48.8",
"0.0063"
]
}
}
]
}
}
]
and I somehow need to reduce it to this:
[
{
"Time": "2021-05-20 12:22:32",
"Max PPV in/s": 0.5494,
"Max Freq Hz": 25.6
},
{
"Time": "2021-05-22 19:15:51",
"Max PPV in/s": 0.0056,
"Max Freq Hz": 7.4
},
{
"Time": "2021-05-22 19:30:51",
"Max PPV in/s": 0.0050,
"Max Freq Hz": 60.2
}
]
What is going on here? The values in the “Cell” array correspond to the “ColumnTitle” array. The values and dates are stored as strings for various reasons that cannot be addressed, let’s take it as a given. A document may have one set of values as you see in the first document, or multiple sets of values as you see in the second document. Regardless, for each set of values, I must compare all “PPV in/s” values, find the max, and pair with the corresponding “Freq Hz”. Add time and that’s what I present as the desired outcome. Presenting the results in a new array after “Cell” is also acceptable.
I’ve been going around in circles trying to figure out how to implement different stages in an aggregation pipeline. Any help would be much appreciated. Thank you in advance!