Inconsistent View Results

I am running into an issue where query results from a view are inconsistent when using the Java Couchbase Client 1.1. I run the same query directly in a browser and I get consistent results. I have run the query on each of the three nodes in the cluster; debugging shows that each node has returned inconsistent results through the java client, but in a browser the results are consistent for each node.

Here is the map:

function (doc, meta) {
  var data = doc.data;
  if(data) {
    emit([data.company_number, data.status], {
      applicationNumber: data.application_number,
      formId: data.id,
      status: data.status});
  }
}

And the reduce:

function(keys, values, rereduce) {
  var index;
  var maxApp = {applicationNumber:""};
  for (index in values) {
    if (values[index].applicationNumber > maxApp.applicationNumber) {
      maxApp.applicationNumber = values[index].applicationNumber;
      maxApp.formId = values[index].formId;
      maxApp.status = values[index].status;
    }
  }
  return maxApp;
}

The unreduced results are:

{"total_rows":89,"rows":[
{"id":"2b4325a8-0d12-11e3-9728-180373e4f256","key":[30951,"APPROVED"],"value":{"applicationNumber":"30951-00001","formId":"2b4325a8-0d12-11e3-9728-180373e4f256","status":"APPROVED"}},
{"id":"460_848934560","key":[30951,"APPROVED"],"value":{"applicationNumber":"30951-00002","formId":"460_848934560","status":"APPROVED"}}
]
}

Sometimes the java client returns the "30951-00001" application number incorrectly, and other times the "30951-00002" correctly - as if sometimes it doesn't know about the "30951-00002" row.

Any ideas?

1 Answer

« Back to question.

Hello,

Were you able to identify the source of the problem?
Have you tested with debug enabled?

Regards
Tug
@tgrall