Firstly i am sorry if this question is sounding too stupid. But i am recently learning N1QL and need some output for my statement. My bucket name is MultiSiteResponseTime and I am trying to get the result of all the hours by executing "select HourResponsetime.Hour from MultiSiteResponseTime;". But i don't get any result. From what i have understood, if you want to access the inner elements then you have to use it like so HourResponsetime.Hour but i am not sure where i am wrong. Also if you could help me in getting result of a specific key, for example i would like to know the result of ResponseTime present for Hour 1.
{
"Para": "ResponseTime",
"Date": "18-04-2016",
"Qantas": {
"HourResponsetime": [
{
"Hour": 0,
"ResponseTime": 8
},
{
"Hour": 1,
"ResponseTime": 9
},
]
}
}
This is by no mean a stupid question!
The dotted path syntax "A.B
" works well when A
is a JSON Object. Your document structure has an array of objects in HoursResponseTime
, that's why it doesn't work. The way to go is to use an array index selector with an asterisk: A[*]
.
Also, the path syntax starts from the root of the document's content. Here you have an intermediary object Qantas
, which you should make part of the path.
This gives us:
SELECT Qantas.HourResponsetime[*].Hour FROM MultiSiteResponseTime;
This should return an array of Hour
s for each document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With