在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/