def search(self): """ text / tags / docids (text与tags至少有一项不为空,docids为必填项) / timeout (可选) :type docids: string return: 返回错误编码或respone """ if not self.appid: raise tornado.gen.Return(401) if not self.text and not self.tags: raise tornado.gen.Return(401) if not self.docids: raise tornado.gen.Return(401) # 还原docids docidslist = self.docids.split("-") if len(docidslist) != 2: raise tornado.gen.Return(401) else: docidslist[0] = str(utils.encodeDocid(int(self.appid), int(docidslist[0]))) docidslist[1] = str(utils.encodeDocid(int(self.appid), int(docidslist[1]))) data = {} data["docids"] = docidslist[0] + "-" + docidslist[1] if self.text: data["text"] = self.text if self.tags: data["tags"] = self.tags if self.timeout: data["timeout"] = self.timeout self.body = urllib.urlencode(data) resp = yield self.client() raise tornado.gen.Return(resp)
def index(self): self.docid = str(utils.encodeDocid(int(self.appid), int(self.docid))) data = {"docid": self.docid} if self.tags: data["tags"] = self.tags if self.text: data["text"] = self.text self.body = urllib.urlencode(data) resp = yield self.client() raise tornado.gen.Return(resp)