def on_post(self,req,resp,index): if index not in self.indexs: raise falcon.HTTPError(falcon.HTTP_404,'invalid_grant',"invalid index name %s" % index) params = req.context params['index'] = index result = sphandle.search(kw) if result[0] == -1: raise falcon.HTTPError('invalid_sql_syntax',str(result[1])) result={'result':result[1]} resp.body = JSONEncoder().encode(result)
def on_get(self,req,resp,index): if index not in self.indexs: raise falcon.HTTPError(falcon.HTTP_404,'invalid_grant',"invalid index name %s" % index) params = req.params opt = params.get('opt') kw = sphandle.parse(opt) kw['keyw'] = params.get('keyw') kw['page'] = int(params.get('page',1)) kw['pageSize'] = int(params.get('pagesize',sconf.PAGE_SIZE)) kw['index'] = index kw['orderBy'] = params.get('order') kw['groupBy'] = params.get('group') kw['fields'] = params.get('fields','') result = sphandle.search(kw) if result[0] == -1: raise falcon.HTTPError(falcon.HTTP_400,'searchd error',str(result[1])) result={'result':result[1]} resp.body = JSONEncoder().encode(result)