【问题标题】:Elasticsearch query gives "No handler for uri" using httplib in PythonElasticsearch 查询在 Python 中使用 httplib 给出“没有 uri 处理程序”
【发布时间】:2015-07-02 19:52:05
【问题描述】:

我正在使用官方的 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 中?我在这里错过了什么?

【问题讨论】:

    标签: python google-app-engine elasticsearch urllib2 httplib


    【解决方案1】:

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

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

    什么时候应该是:

    c.request('GET', '_search', None, {})
    

    奇怪的是,urlfetch 存根的latest source code version 似乎与shipped SDK 非常不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-03
      • 2017-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多