Map/Reduce is not working properly


#1

I am using CBL 1.0.4 for android i am using Map/reduce in queries but its working on Android 4.4.4 but fails on 4.4.2

Query query = database.getView("ordersByDateView").createQuery();
query.setStartKey("2014-01-01");
query.setEndKey("2014-02-01");
// First run without reduce to get the individual orders for January '14:
query.setMapOnly(true);
QueryEnumerator result = query.run();
for (Iterator<QueryRow> it = result; it.hasNext(); ) {
    QueryRow row = it.next();
    Log.w("MYAPP", "On %s: order for $%f", row.getKey(), ((Double)row.getValue()).doubleValue());
}
// Now run with reduce to get the average order price for January '14:
query.setMapOnly(false);
QueryEnumerator result = query.run();
QueryRow aggregate = result.next();
Log.w("MYAPP", "Average order was $%f", ((Double)aggregate.getValue()).doubleValue());

#2

Hi @psrinivasgoud

Could you please provide log from logcat?

Please add following codes to enable detailed logging before creating Manager instance?

Manager.enableLogging(Log.TAG_SYNC_ASYNC_TASK, Log.VERBOSE);
Manager.enableLogging(Log.TAG_SYNC, Log.VERBOSE);
Manager.enableLogging(Log.TAG_QUERY, Log.VERBOSE);
Manager.enableLogging(Log.TAG_VIEW, Log.VERBOSE);
Manager.enableLogging(Log.TAG_DATABASE, Log.VERBOSE);

Thanks!
Hideki


#3

@hideki thanks for reply i am trying this post https://github.com/couchbase/couchbase-lite-java-core/issues/637 answer i ll get back to you whether its working or not.