I have changed the order of index keys, structure.
embarkDate is <= so it has both low and high bound and moved to leading
debarkDate is >= no high bound so moved to trailing. pre 5.0.0 If high bound is missing next key high bound will not passed to indexer.
You really doesn’t need array index. you need just array has single element so used FIRST expression. This will not hit keysize
moved array to end.
Change query projection.
Unnest repeats parent document instead just get boarding info as array do the looping in application.
As you are getting array the limit value can be much lesser.
CREATE INDEX IX_teamMember_Cover_reporting ON default (propertyId,
(FIRST 1 FOR s IN teamMemberBoardingStatuses WHEN s.statusChangedDate IS NOT MISSING END),
DATE_FORMAT_STR(embarkDate, "1111-11-11"),
DATE_FORMAT_STR(debarkDate, "1111-11-11"),
firstName, middleName, lastName, birthDate, citizenshipCountryCode, genderCode, phones, photoMediaItemId,
identifications, stateroom, teamMemberNumber, departmentCode, teamMemberBoardingStatuses)
WHERE ((type = "TeamMember") and (not ((meta().id) like "_sync%")));
SELECT meta(tm).id, tm.firstName, tm.middleName, tm.lastName, tm.birthDate, tm.citizenshipCountryCode, tm.genderCode,
tm.phones, tm.photoMediaItemId, tm.identifications, tm.stateroom, tm.teamMemberNumber, tm.departmentCode,
ARRAY b FOR b IN tm.teamMemberBoardingStatuses WHEN b.statusChangedDate IS NOT MISSING END AS boardingStatus
FROM default tm
WHERE tm.type = "TeamMember" AND meta(tm).id NOT LIKE "_sync%"
AND tm.propertyId = "AL"
AND (DATE_FORMAT_STR(tm.debarkDate,"1111-11-11") >= "2018-03-19")
AND (DATE_FORMAT_STR(tm.embarkDate,"1111-11-11") <= "2018-03-22")
AND (FIRST 1 FOR s IN tm.teamMemberBoardingStatuses WHEN s.statusChangedDate IS NOT MISSING END) = 1
Order by meta(tm).id
Limit 10 Offset 0
;
If you still prefer UNNEST you can add it with same index and query