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];
}
I have migration lined up soon. No reason for not migration. Pl. Warn me if there could be any
Map code:
function (doc, meta) {
if(doc.identifier && doc.identifier == “RawActivityMetric” && doc.status == “ACTIVITY_STARTED”){
var posSplit = doc.positionId.split("|");
if(posSplit.length == 4){
var trainingId = posSplit[0];
var activityId = posSplit[3];
emit([doc.accessId, trainingId, doc.userId, doc.version], [doc.datetime, activityId]);
}
}
}
all docs have the fields identifier,accessId , status,positionId,userId,datetime and version(This version is different from meta.rev)
doc.datetime is number and all other fields are String.
My Progress today:
Querying from Web console I could fetch all 1K records multiple times without any inconsistency. I guessed some inconsistency between gson(used in my application) and couchbase-client. And update couchbase-client to 1.2.3 and replaces gson with jackson 2.2.2.
Query is working since lib updates… but I cannot confirm due to the randomness of issue.
Is there any know inconsistency with gson or with couchbase-server 2.0.1 ?
I’m not aware with any issues with gson, but if a document isn’t well-formed json it will be treated as a BLOB and hence you won’t be able to access individual fields in it. (You can check for this by testing the meta.type field - this will be “json” for correctly-formatted JSON documents.