0

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?

mikewied
  • 5,273
  • 1
  • 20
  • 32
GreenRover
  • 1,486
  • 1
  • 14
  • 33

1 Answers1

0

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"
}
kruthar
  • 309
  • 1
  • 2
  • 10
  • I checked this allreay by not set (start|end)key= – GreenRover Aug 05 '15 at 08:58
  • My apologies I posted the incorrect document in my answer, I just edited it with the document that represents the lower bound of your query. If my bucket had only the document you posted as an example, then running your query would return no results. Adding the document from my answer to the bucket, then I receive it back when I run your query. Your View and Query work. Are you getting any errors? or is the query succeeding with no results? Can you run a small test: run the query with no startKey or endKey, then use one of the results you get as the startKey and endKey? – kruthar Aug 05 '15 at 13:26