Effective array index to match multiple items

@atom_yang , @mikehcumail Use 4.6.0 or 4.6.1 https://issues.couchbase.com/browse/MB-21720

for 4.5.1 As @geraldss suggested in Additional help with N1QL dynamic attribute key use Intersect.

Also try this.

SELECT meta().id FROM retailcloudPortalDev WHERE docType='experience' AND ANY v IN supportedChannelIds SATISFIES v='channel:best_buy' END AND 'channel:tmo' IN supportedChannelIds;

If supportedChannelIds array is not too big include in the index so that it will make covered. Also you can remove docType from index keys because in index condition it is equality predicate.

CREATE INDEX test ON retailcloudPortalDev(DISTINCT ARRAY v FOR v IN supportedChannelIds END, supportedChannelIds ) WHERE docType='experience';

2 Likes