python - Elasticsearch 查询在 Python 中使用 httplib 给出 "No handler for uri"

标签 python google-app-engine elasticsearch urllib2 httplib

我用的是官方elasticsearch-py用于连接到 Elasticsearch 的本地实例的库(localhost,端口 9200,ES 版本 1.6.0)。这在独立的 Python 脚本中运行良好,但我无法让它与 Google App Engine 一起使用,出现以下错误:

No handler found for uri [http://localhost:9200/transaction/websession/_search] and method [GET]

经过一些调试,我将问题缩小到 App Engine 对 httplib 的使用用于 urlfetch RPC 代理。

所以基本上,我可以这样做:
r = urllib2.urlopen('http://localhost:9200/transaction/websession/_search')
r.read()

但不是这个:
c = httplib.HTTPConnection('localhost:9200')
c.request('GET', 'http://localhost:9200/transaction/websession/_search', None, {})
c.getresponse().read()

这是 Python 中的错误吗?还是在 Elasticsearch 中?我在这里想念什么?

最佳答案

我找到了答案。问题在于当前的 App Engine SDK。请求是这样创建的:

c.request('GET', 'http://localhost:9200/transaction/websession/_search', None, {})

什么时候应该是:
c.request('GET', '_search', None, {})

奇怪的是 latest source code version的 urlfetch stub 似乎与 shipped SDK 非常不同.

关于python - Elasticsearch 查询在 Python 中使用 httplib 给出 "No handler for uri",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31193488/

相关文章:

python - Beautifulsoup 网络爬虫问题

python - “函数”对象没有属性 'train_test_split'

Python:按字母顺序迭代 OrderedDict

node.js - Google App Engine Nodejs 错误 409

elasticsearch - 我可以在ElasticSearch日志中忽略这些查询异常吗?

python - PyMC3 将随机协方差矩阵传递给 pm.MvNormal()

python - google-app-engine 不支持库 "endpoints"。

google-app-engine - 为什么 Google App Engine 不支持自定义 404 处理程序?

elasticsearch - 从 kibana 导出到 csv/excel

Elasticsearch 查询结果过多