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

标签 python http elasticsearch apache-zeppelin elasticsearch-py

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

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

关于python - elasticsearch-py搜索查询比等效的curl慢得多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49396600/

相关文章:

python - 如何检查模块是否已导入

python - 如何使用pyinstaller将多个python文件编译成单个.exe文件

python - 使用 Excel/Python 从 Excel 中提取信息(通过更新数组)

http - 处理原始 HTTP 请求

elasticsearch - Logstash无法从Beats中读取logtype字段

python - "localhost"与 "127.0.0.1"性能

http - 当content-type header为image/jpeg时,HTTP响应的内容数据格式是什么?

html - 我怎样才能通过 AngularJS 进行分页?

mysql - 全文检索数据库和超过 2 亿条记录

elasticsearch - elasticsearch方面或过滤器