This is actually more of a 2 part question. First one is how to query with N1QL my Docs to find all which are in a certain bucket and also in a category. The issue is that i want to be able to dynamically create the query since i dont know what the user will select. For example he might not select only 2 buckets but no category filter. Would that mean that i would have to check if there is a category filter if not use a template that does not use a IN for Category ? Or would it be better to pass the filter as an $X to the template ?
Second how in my below query can i get all contact’s which have one of the buckets selected returned ? When i try the IN or where clause i get no result back
SELECT meta().id as DocId, d.first_name || " " || IFMISSINGORNULL(d.middle_name || " ", "") || d.last_name as Name,
ARRAY {lower(v.type):
CASE WHEN LENGTH(v. `number`) = 10 THEN
"(" || SUBSTR(v.`number` , 0,3) || ") " || SUBSTR(v.`number` , 3,3) || "-" || SUBSTR(v.`number` , 6,4)
else
v.`number` END } FOR v IN d.phones END AS phones,
ARRAY {lower(v.type):v.`address`} FOR v IN d.emails END AS emails,
(SELECT text, meta().id as DocId
FROM `Contacts`
USE KEYS d.buckets) AS buckets,
(SELECT text, meta().id as DocId
FROM `Contacts`
USE KEYS d.categories) AS categories,
FROM Contacts as d
where _type = 'contact'
i tried for example and d.buckets IN (leadbucket::086D59BF-0549-41F3-A79D-5BD9650D9DD5
)