繁体   English   中英

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"}}}
)

需要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"}}}
'

基本上会立即返回。

为什么python库的性能如此差,如何使它更快?

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

我不明白为什么这行得通,但是如果我向查询添加filter_path ,它的返回速度与原始curl一样快:

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"}}}
)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM