使用Elasticsearch python扫描助手获取命中计数?

时间:2018-08-14 18:51:28

标签: python elasticsearch

我想检索点击数,同时也只执行一个Elasticsearch查询。仍然可以使用helper.scan函数而不是求助于scroll吗?

这就是我现在拥有的:

from elasticsearch import Elasticsearch, helpers
es = Elasticsearch()
index = "index",
query = {"query": {"query_string": {"query": "foobar"} }}

count = es.count(index=index, body=query)
print(count)

results = helpers.scan(client=es, scroll="1m", index=index, query=query)
for result in results:
  print(result)

0 个答案:

没有答案