Hi,
I have documents like this:
{
“type”: “foo”,
“id”: 1,
nase:
“sections”: [
{“name”:“foo”,
“ids”:[1,9,17,55]
},
{“name”:“bar”,
“ids”:[13,67]
}
]
}
Now I want the id of all documents that contains 13 anywhere in “ids” in one of the sections elements.
I added a index:
CREATE INDEX metaplacement
ON
test (type
, distinct array
( distinct array id for id in section.ids end)
for section
in sections
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
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.
Any ideas?
Thanks, Pascal