I have a class and I am trying to query a view. My view code looks like this:
function (doc, meta) {
if(doc.caseid == "000000000000"){
var result = meta.id.split("-").slice(1,8);
var year = parseInt(result[0]);
var month = parseInt(result[1]);
var day = parseInt(result[2]);
var hour = parseInt(result[3]);
var minute = parseInt(result[4]);
var seconds = parseInt(result[5]);
var mili = parseInt(result[6]);
emit([year,month,day,hour,minute,seconds,mili], doc);
}
}
My cherrypy server code looks like this:
class HelloWorld:
@cherrypy.expose
def index(self):
if 'count' not in cherrypy.session:
cherrypy.session['count']=0
cherrypy.session['count'] +=1
cb = Bucket(connection_string, password=passwd)
q = Query()
q.limit = 5 # Limit to 5 results
q.mapkey_range = ([2015,1,None,None,None,None,None], [2015,12,None,None,None,None,None])
rows = cb.query('_design//tt ', 'tracetest', query=q)
out =""
try:
for row in rows:
out += row
except CouchbaseError as e:
if e.is_data and isintance(e, NotFoundError):
# handle not found
pass
elif e.is_network:
return "Got network error"
elif e.is_data:
return "Got other data-related error"
else:
ekey = " key : "
if e.key:
ekey += key
else:
ekey += " N/A"
return "Got unhandled error code"+ekey
n = "Hello world! %s" % (cherrypy.session['count'],)
return out
I am trying to get at a view called _design//tt/view/tracetest
Am I referencing this correctly? Is this the right way to do a compound key query?
My url looks like http://localhost:8092/telemetry-trace/design/dev%2Ftt/_view/tracetest?stale=false&inclusive_end=false&connection_timeout=60000&limit=10&skip=10
{"total_rows":59,"rows":[
{"id":"39CEED3C8145F1848AF0C7F76C34596A-2015-3-2-15-16-51-653000000",......
]
}
Show results looks like this
Key Value
[2015,2,25,16,19,8,47000000]
39CED3B5B88FD6232EE65E918A356C53-2015-2-25-16-19-8-47000000 .... {<Some Doc data>}
On the cherrypy server I get the following output
Got unhandled error code key : N/A
I have verified that server can do a get(someid), so I know its connected properly. I think my problem here is referencing the view.
Again, what I would like to know is am I referencing this correctly? Is this the right way to do a compound key query?