N1QL query - Index Creation

“Explain” tells you what index(es) the query is using, it doesn’t tell you what index you should create. “Advise” is probably what you are looking for. For example, when I run “Advise” on that query in 6.6 Enterprise (or via the web-based query advisor), it recommends:

Covering Index Recommendations

CREATE INDEX adv_ALL_CustRteRltnshps_Type_CtryCd ON `masterdata-target` (ALL `CustRteRltnshps`,`$Type`,`CtryCd`)

Index Recommendations

CREATE INDEX adv_ALL_CustRteRltnshps_Type ON `masterdata-target`(ALL `CustRteRltnshps`,`$Type`)