本文介绍了如何从弹性搜索索引检索所有文档ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从弹性搜索索引中检索所有文档ID(内部文档_id)?如果我在该索引中有2000万个文档,那么最好的方法是什么?
How to retrieve all the document ids (the internal document '_id') from an Elasticsearch index? if I have 20 million documents in that index, what is the best way to do that?
推荐答案您可能希望使用扫描和滚动API 。
许多客户端库都有准备好的帮助程序来使用该界面。例如,使用elasticsearch-py,您可以执行以下操作:
Many client libraries have ready helpers to use the interface. For example, with elasticsearch-py you can do:
es = elasticsearch.Elasticsearch(eshost) scroll = elasticsearch.helpers.scan(es, query='{"fields": "_id"}', index=idxname, scroll='10s') for res in scroll: print res['_id']更多推荐
如何从弹性搜索索引检索所有文档ID
发布评论