我想检索点击数,同时也只执行一个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)