Beispiel #1
0
 def handle_cmd_query(self, req):
     sort = req.get_list('sort', [])
     type = req.get_string('type', u'_id')
     results, kws = self.indexdb.query(req.qs, req.start, req.size, sort=sort)
     if type == '_id':
         d = [doc.docid for doc in results]
     elif type == 'id':
         d = [util.fromjson(doc.document.get_data())[self.indexdb.get_idfield()] for doc in results]
     elif type == 'doc':
         d = [util.fromjson(doc.document.get_data()) for doc in results]
     else:
         raise AWIPRequestInvalid('bad value for "type"')
     return { 'results': d , 'keywords': kws or []}
Beispiel #2
0
 def handle_cmd_update(self, req):
     id = req.id
     try:
         doc = self.indexdb.get_document(id)
         docdata = util.fromjson(doc.get_data())
     except Exception, e:
         logger.warn('%r: Exception when retrieving doc %r', self.addr, id, exc_info=True)
         raise AWIPRequestInvalid('failed to read the doc: ' + str(e))
Beispiel #3
0
 def handle_cmd_get(self, req):
     ret = []
     for id in req.ids:
         try:
             doc = self.indexdb.get_document(id)
             ret.append(util.fromjson(doc.get_data()))
         except:
             logger.warn('%r: Exception when retrieving doc %r', self.addr, id, exc_info=True)
             ret.append(None)
     return {
         'status': 'ok',
         'results': ret,
     }