Given documents with this shape:
{
id: 12345,
answers: [
{ q: 'question 1', v: 'answer1'},
{q: 'question 2', v: 'answer2'}
]
},
{
id: 23456,
answers: [
{q: 'question 2', v: 'answer2'}
]
}
I want to find all documents where none of the answers is for ‘question 1’. Question 1 may never be answered.
SELECT bucket.* FROM bucket WHERE type='document'
AND EVERY a WITHIN answers SATISFIES a.q <> 'question 1' END
The query above returns 0 results (which is wrong), while the query below returns the correct number of results:
SELECT bucket.* FROM bucket WHERE type='document'
AND NOT ANY a WITHIN answers SATISFIES a.q = 'question 1' END
I don’t understand why the first and second queries aren’t functionally equivalent. What am I missing?