I have a query where i get contacts based on a tag where query looks like this
select META(c).id,
e.address,
c.tags
FROM Contacts c
UNNEST c.emails e
WHERE c._type = 'contact'
AND ANY v IN c.tags SATISFIES v = "tag::EA5DE0FB-34B0-4F7C-B631-177D6BD2F65E" END
how would i go about if i wanted the above query but also exclude where any contact has a tag of
“tag::7F76891A-1C6B-4CD3-9D34-57A1727F45A0”
select META(c).id,
e.address,
c.tags
FROM Contacts c
UNNEST c.emails e
WHERE c._type = 'contact'
AND ANY v IN c.tags SATISFIES v = "tag::EA5DE0FB-34B0-4F7C-B631-177D6BD2F65E" END
AND NOT (ANY v IN ctags SATISFIES v = "tag::7F76891A-1C6B-4CD3-9D34-57A1727F45A0" END)
Here is the interesting part, if i run the sample query i get results that don’t make sense
In my test case if i run with no Satisfy filter i get 208 Docs
If i use " AND ANY v IN c.tags SATISFIES v = “tag::7F76891A-1C6B-4CD3-9D34-57A1727F45A0” END"
i get 3 Docs which means by my account based on 208 records there should be 205 which don’t have that tag.
If i now apply this filter only AND NOT (ANY v IN c.tags SATISFIES v = “tag::7F76891A-1C6B-4CD3-9D34-57A1727F45A0” END)
I get 86 Records so what causes this ?
Earlier query array contains tag1 and not contain tag2
If you want documents that doesn’t contain tag1
select META(c).id,
e.address,
c.tags
FROM Contacts c
UNNEST c.emails e
WHERE c._type = 'contact'
AND NOT (ANY v IN ctags SATISFIES v = "tag::7F76891A-1C6B-4CD3-9D34-57A1727F45A0" END);
OR
select META(c).id,
e.address,
c.tags
FROM Contacts c
UNNEST c.emails e
WHERE c._type = 'contact'
AND EVERY v IN ctags SATISFIES v != "tag::7F76891A-1C6B-4CD3-9D34-57A1727F45A0" EN);