Query not working properly with keys

#1
  1. I am using couch base lite 1.0.4 for android when i running follwoing Query i am getting count is 0 but data is presenet in CBl.
com.couchbase.lite.View view = database.getView("getRelated");
if (view.getMap() == null){
    Mapper mapper = new Mapper() {
        @Override
        public void map(Map<String, Object> document, Emitter emitter) {
            java.util.List<Object> keys = new ArrayList<Object>();
            keys.add(document.get("relation"));
            keys.add(document.get("summery"));
            emitter.emit(keys, document.get("_id"));
        }
    };
    view.setMap(mapper, "1");
}
Query query = view.createQuery();
java.util.List<Object> keys = new ArrayList<Object>();
keys.add("text");
keys.add("ok");
query.setKeys(keys);
try {
    QueryEnumerator enumerator =  query.run();
    Log.i(Application.TAG,enumerator.getCount()+"");
} catch (CouchbaseLiteException e) {
    e.printStackTrace();
}
#2

Hi @psrinivasgoud,

It should return number of rows. http://developer.couchbase.com/mobile/develop/references/couchbase-lite/couchbase-lite/query/query-enumerator/index.html#int-count--get-

Give us few days to reproduce and investigate this issue.

I filed the issue on github repo’s issue tracker.

Thanks!
Hideki

#3

@hideki Thanks for the reply its working according to https://github.com/couchbase/couchbase-lite-java-core/issues/637 answer given by sergio91pt .I request couchbase people to improve documentation with more examples specially with composite key which i dint find here http://developer.couchbase.com/mobile/develop/guides/couchbase-lite/native-api/query/index.html there is no example for query.setKeys() method thanks.

#4

Hi @psrinivasgoud,

I am glad to hear you could solve the problem.

Following is link to unit test case for query with compound keys. It might help you.

Have a nice weekend!