Issues returning unique values

We are having some performance issues with our ongoing project because we get back lots of values from our views and cannot group them because we don't use any reduce function.

All our documents have the same structure, and look like this:

{ "country_name": "Libya",
   "cell_id": 1428,
   "values": {
       "sm_n": 5.041993618011475,
       "dir": "A",
       "sm": 29.116374969482422 },
   "gpi": 1626595,
   "time": {
       "hour": 19,
       "month": 7,
       "second": 28,
       "year": 2008,
       "jd": 2454657.3176934035,
       "day": 9,
       "minute": 37  },
   "lat": 30.044195,
   "country_id": 138,
   "lon": 15.034694  }

A view, which causes this problem looks like that:

function (doc, meta) {
  emit(doc.cell_id, doc.gpi);
}

Here, we want all gpi - values which share the came cell_id back. problem here is that lots of document share the same gpi and the same cell_id. The group function is no option since we found no reduce to perform here. Since we get back so many duplicate values we have to put in a set in python so they are unique we lose a lot of performance due to iterating through all values couichbase returns.

Does anyone have any idea how we could solve this problem? Thanks!

I just got my uniques question answered. Hope it helps!

http://www.couchbase.com/communities/q-and-a/how-count-uniques-view

we tried it with this reduce already:

function(keys, values, rereduce) {
return values.filter(function (e, i, arr) {
return arr.lastIndexOf(e) === i;
});
}

The problem here is that we find the error "reduction too large" in the error.log, and t keeps indexing forever.

0 Answers

No answers yet