I have a document that looks like this:
{
"startTime": 123,
"endTime": 932345235,
"type": "results",
"validationResults": [
{
"name": "xyz",
"ruleViolated": 1,
"details": [
{
"timeStamp": 132345235,
"place": "abc",
"acknowledged": false
},
{
"timeStamp": 7658,
"place": "bcd",
"acknowledged": true
}
]
},
{
"name": "xyz",
"ruleViolated": 2,
"details": [
{
"timeStamp": 132345235,
"place": "abc",
"acknowledged": false
},
{
"timeStamp": 7658,
"place": "bcd",
"acknowledged": true
}
]
},
{
"name": "random",
"ruleViolated": 1,
"details": [
{
"timeStamp": 9679,
"place": "abc",
"acknowledged": false
},
{
"timeStamp": 12412,
"place": "bcd",
"acknowledged": true
}
]
}
]
}
Here the startTime and endTime is the range for which the check was made while creating the doc.
Now I want the results within a certain time range [x,y] such that for every result in validation results, their details data get filtered within that range and i get the data in the same format with details being in the required range.
I tried using the query:
SELECT a.* FROM bucketName a unnest a.validationResults as b unnest b.details as c where ( (a.startTime <= 1462042800000 AND a.endTime >= 1462042800000) OR (a.startTime >= 1462042800000 AND a.startTime <= 1462043025018) ) AND (c.timeStamp between 1462042800000 and 1462043025018) and a.type=“results”
Issue is a.* is returning me every possible datapoint and filtering is only done when i do c.* but that is not the format that i want.
Any help is appreciated