如何从弹性搜索索引检索所有文档ID

编程入门 行业动态 更新时间:2024-10-12 22:26:18
本文介绍了如何从弹性搜索索引检索所有文档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

本文发布于:2023-11-28 12:13:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹性   索引   文档   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!