Query.keys - is it AND or OR?

Apologies for such a basic question. I’m using Couchbase Lite 1.3.1 Java version on Android. I’m unsure what the Query.keys exactly mean. The javadoc says “If non-nil, the query will fetch only the rows with the given keys.”.

Does that mean that only the documents emitted with all of the keys present in the set will be returned? Or is it a union, that is, any document stored under any key from the set will be returned?

Thank you.

Any value emitted from the queried view using any of the keys in the set will be returned in the query. So to use the language from your title: “OR.”

Thank you kindly. I also thought the keys to work in the OR fashion, I’m using it to mass-select items. In my case it doesn’t seem to work properly though - if the set is of size 3 or larger, 0 items are always returned. I am using a composite keys though (List of Strings) with the ForestDB database, maybe there is a bug in Couchbase Lite or ForestDB? I’ll create a simple demo project to reproduce the issue.

Yup, probably a bug in ForestDB. Opened an issue report here: https://github.com/couchbase/couchbase-lite-core/issues/42

That’s the wrong repo actually. The repo you want to file this on is “couchbase-lite-Java-core” not “couchbase-lite-core”. The latter is the new C++ engine for our unreleased 2.0 product.

@hideki Can you move the ticket?

It’s best not to think of queries as returning documents. Tthey return rows from the view’s index. In a regular query, each row will indicate which document emitted it; but in a reduced or grouped query it won’t because each row is an aggregate.

Apologiies, I will make sure next time to post the ticket properly.