Couchbase range query

228 views Asked by At

i have testa couchbase 4 server, to store sensor measurement data.

I have following view:

function (doc, meta) {
  if (doc.aks) {
    emit([doc.aks, doc.timestamp], {
      value: doc.value,
      status: doc.status
    });
  }
}

Here an example document:

{
   "timestamp": 1199180981,
   "value": 0,
   "status": 2147483650,
   "aks": "BN028:H23:VS:001:Zustand"
}

I try now following query to this view: Give me a timerange of values for a single sensor.

/_view/timeline?stale=false&startkey=["BN020:H03:ZW:102:MC_t_return",12675419334]&endkey=["BN020:H03:ZW:102:MC_t_return",13675419334]

But this will give no result.

I get an result if i jsut use startkey= or endkey= but not if i use both. What do i wrong?

1

There are 1 answers

2
kruthar On

Make sure you actually have data in your bucket that would fall within your range. I used your View and your Query and received results. Your example document is not within the range, the aks is wrong and the timestamp is too early. If you add a document that is in the range you should receive it back. This one is the lower bound of your range:

{
    "timestamp": 12675419334,
    "value": 0,
    "status": 2147483650,
    "aks": "BN020:H03:ZW:102:MC_t_return"
}