I have documents like this:
Now I want the id of all documents that contains 13 anywhere in “ids” in one of the sections elements.
I added a index:
type, distinct array
( distinct array id for id in section.ids end)
id) WHERE type=“foo”
and do this query:
select id from test
where type=“foo” and sections is not missing AND any section in sections satisfies
any id in section.ids satisfies id = 13 end
This works perfectly so far, I get the expected result. But for each element found, N1QL fetches the document.
The index itself works (if it finds 3 matching documents there are 3 out in “IndexScan”, but then these 3 documents are fetched. I don’t get why, because all needed fields are stored in the index, so this query should be full index covered without touching the kv engine.