def textanalyze(self,index_name, analyzer, text):
# Create JSON string for request body
reqobject={}
reqobject['text'] = text
reqobject['analyzer'] = analyzer
io=StringIO()
json.dump(reqobject, io)
req_body = io.getvalue()
# HTTP request to Azure search REST API
conn = httplib.HTTPSConnection(self.__api_url)
conn.request("POST",
u"/indexes/{0}/analyze?api-version={1}".format(index_name, _AZURE_SEARCH_API_VERSION),
req_body, self.headers)
response = conn.getresponse()
#print "status:", response.status, response.reason
data = (response.read()).decode('utf-8')
#print("data:{}".format(data))
conn.close()
return data
评论列表
文章目录