How to get array positions at doc using N1QL?

You should use index and query in the Using array index to speed up update query instead of N1QL and sub-doc mutation.

SELECT FIRST ARRAY_POS(schedule, v) FOR v IN schedule WHEN  v.flight = "AF678" END
 FROM `travel-sample`  WHERE ..........

If more than one array element matches flight = “AF678” it gives first matched array position

1 Like