elasticsearch-py 搜索查询比等效的 curl 慢得多

elasticsearch-py search queries substantially slower than curl equivalent

在 Zeppelin 笔记本中,运行使用 elasticsearch-py 5x

执行以下查询
es = Elasticsearch(["es-host:9200"])
es.search(index="some_index", 
          doc_type="some_type", 
          body={"query": {"term": {"day": "2018_02_04"}}}
)

return 需要 28 分钟。

从同一个笔记本,使用 curl 到 运行:

curl -XGET 'http://es-host:9200/some_index/some_type/_search?pretty' -H 'Content-Type: application/json' -d'
{"query": {"term": {"day": "2018_02_04"}}}
'

return基本上是瞬间。

为什么 python 库性能这么差,如何才能让它更快?

这不是我见过的东西,根据这个问题判断我猜你的环境有问题。

我不明白 为什么 这行得通,但是如果我在查询中添加 filter_path,它 returns 和原始卷曲一样快:

es = Elasticsearch(["es-host:9200"])
results = es.search(index="some_index", 
      doc_type="some_type", 
      filter_path=['hits.hits._id'],
      body={"query": {"term": {"day": "2018_02_04"}}}
)

如果有人对此行为有解释,我将不胜感激。