Hi
I have a document which has 2 arrays, is it possible to create a single index whose participating key in index would be a merge of 2 arrays and not cartesian product.
Regards,
Venkat
Hi
I have a document which has 2 arrays, is it possible to create a single index whose participating key in index would be a merge of 2 arrays and not cartesian product.
Regards,
Venkat
Yes, only in Couchbase
You can create a single FTS index with two arrays and avoid the cartesian product.
See: https://dzone.com/articles/arrays-in-json-modeling-querying-and-indexing-perf
In GSI if index field is same from both arrays ARRAY_CONCAT()
CREATE INDEX ix1 ON default (DISTINCT ARRAY v.id FOR v IN ARRAY_CONCAT(a,b) END);
SELECT * FROM default WHERE ANY v IN ARRAY_CONCAT(a,b) SATISFIES v.id > 10 END;
Hi @vsr1
Thanks for the solution.
Can you also suggest how to get it work if one of the Array is Missing?
Regards,
Venkat
ARRAY_CONCAT(IFMISSINGORNULL(a,),IFMISSINGORNULL(b,))