簡體   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