Hello,
I am having trouble creating a proper index for a n1ql query/document.
Here is my document structure:
{
"viewEvents": [
{
"deviceType": "",
"country": "USA",
"endOffset": 19615,
"product": "",
"postalCode": "90045",
"type": "LINEAR",
"userId": "641469777",
"viewDuration": 114,
"airingId": "4321341",
"itemId": "1233442",
"startOffset": 9185,
"profileId": "653667813",
"contentDuration": 28800,
"startTime": 1503376385539,
"portionViewed": 0,
"attributes": {},
"endTime": 1503376500492,
"airingStartTime": 1503367200000,
"stationId": "54325432",
"timestamp": 0
}
],
}
Here is my n1ql query.
select viewEvents.*, meta(sentvUserViewEventList).id as _ID, meta(sentvUserViewEventList).cas as _CAS from sentv_user_data sentvUserViewEventList UNNEST sentvUserViewEventList.viewEvents viewEvents where meta(sentvUserViewEventList).id like ‘user_view_event::%’ and viewEvents.startTime is not missing and viewEvents.startTime >= $startTime$ order by viewEvents.startTime ASC;
It currently takes about 6-7 seconds to return around 50k documents. I need this to be much quicker if possible.
Here is the start to my index. Any pointers/help is appreciated. Thanks
CREATE INDEX test ON default (DISTINCT ARRAY i.startTime FOR i IN viewEvents END)