How to correctly create Couchbase array index

Multi tool use
Multi tool use


How to correctly create Couchbase array index



I have the following sample document:


{
“_class”: “some.package.Class”,
“creationTime”: 1234567890,
“title”: “title of element”,
“tags”: [ “tag1”, “tag2”, “tag3” ]
}



I now want to query all elements which contain given 2 tags with:


SELECT * FROM bucket WHERE _class = “some.package.Class”
AND (EVERY t IN [“tag1”, “tag2”] SATISFIES t IN tags END) LIMIT 16



I tried to create an index for this query with:


CREATE INDEX some_idx_title ON bucket((distinct (array k for k in tags end)))
WHERE (_class = “some.package.Class”)



But on explaining the select query it does not show up.



How do I have to create the index for this query?




1 Answer
1



The basic answer is that you can't. Array indexes as currently implemented can not satisfy predicates of type EVERY. They can only be used for predicates of type ANY and ANY AND EVERY.



For more information about how to specify array indexes and what predicates they can be used for, consult this reference:



https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/indexing-arrays.html



(This exact question is also answered at somewhat greater length in another forum.)





Here is where I asked the same question and got an answer which solves my problem: forums.couchbase.com/t/how-to-correctly-create-array-index/…
– user1337
Jul 2 at 12:13







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

VYDIbNQ3eltI9s SWClIx,18D2VKd4DZ
Zbm4SLjlJR1ka21w QoMth QgyuKPqAUXEPxVT tQZSiK,rC063wIGb4,dK89GtoZFn2Gh,NjlusI1,9dSCDJcxITpZTexZ3QhCw

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications