1


I am using couchbase version 2.0.1 - enterprise edition (build-170) and java-client version 1.2.2
I have a custom reduce function to get last activity of a user
The response from java client is inconsistent At time I get correct response and most of the time I get null value against valid keys. Even Stale.FALSE doesn't help !!

Number of records in view is around 1 millon and result set for query is arounk 1K key value pairs. I am not sure what could be the issue here.. It will be great if someone can help.

Reduce Function is as below:

function (key, values, rereduce) {
    var currDate = 0;
    var activity = "";
    for(var idx in values){
        if(currDate < values[idx][0]){
            currDate = values[idx][0];
            activity = values[idx][1];
        }
    }
    return [currDate, activity];
}

View Query:

CouchbaseClient cbc = Couchbase.getConnection();
Query query = new Query();
query.setIncludeDocs(false);
query.setSkip(0);
query.setLimit(10000);
query.setReduce(true);
query.setGroupLevel(4);
query.setRange(startKey,endKey);
View view = cbc.getView(document, view);
ViewResponse response = cbc.query(view, query);
manish
  • 21
  • 4
  • Two things. 1) What does your actual view query look like? Paste that in as well. 2) Why don't you just stamp the user's profile when they do something considered 'active' that way you can just use their key and look on that document? – scalabilitysolved Dec 26 '13 at 15:37
  • @avengedsixfold Thanks for input.
    Querying through web terminal gave correct response.
    So there was some compatibility issue with java-client 1.2.2 and google gson which was being used in my application.
    I switched to java-client 1.2.3 and google gson 2.2.4. Things are working as expected now.
    – manish Dec 27 '13 at 06:04

1 Answers1

1

Looks like There was some compatibility issue with java-client 1.2.2 and google gson 1.7.1 which was being used in my application.

I switched to java-client 1.2.3 and google gson 2.2.4. Things are working as great now.

manish
  • 21
  • 4