I wonder if this is possible to be implemented in N1SQL
so, I have multiple documents of the format:
Ex. 1
{
"country_code": "ae",
"chart_timestamp": 1597533003,
"chart_a": {
"1000008721": 6,
"403274099": 2,
"432756187": 1,
"454403780": 3,
"463569251": 4,
"493073807": 7,
"493837285": 5,
"501344243": 8
},
"version": 1
}
Ex. 2
{
"country_code": "ae",
"chart_timestamp": 1597534004,
"chart_a": {
"1000008721": 5,
"403274099": 2,
"432756187": 1,
"454403780": 3,
"463569251": 4,
"493073807": 7,
"493837285": 6,
"501344243": 8
},
"version": 1
}
Ex. 3
{
"country_code": "ae",
"chart_timestamp": 1597535005,
"chart_a": {
"1000008721":3,
"403274099": 2,
"432756187": 1,
"454403780": 5,
"463569251": 4,
"493073807": 7,
"493837285": 6,
"501344243": 8
},
"version": 1
}
Now, what I would like to achieve is a document of the below format, when searching for a key in he chart_a array.
For example, if the key is 1000008721
"position_history":{
"1597535005": 3,
"1597534004": 5,
"1597533003": 6
},
"smaller_position": 3
}
smaller_position is the MIN value of the resulting position_history object
the key of position_history is the chart_timestamp of each individual document
the where clause of the query should be based on the presence of the key (in our case: 1000008721) in each document chart_a ARRAY.
Also, I wonder how should the index look like to index these arrays in every object