What is the fastest way to get all _ids of a certain index from ElasticSearch? Is it possible by using a simple query? One of my index has around 20,000 documents.

解决方案

Edit: Please read @Aleck Landgraf's Answer, too

You just want the elasticsearch-internal _id field? Or an id field from within your documents?

For the former, try

curl http://localhost:9200/index/type/_search?pretty=true -d '

{

"query" : {

"match_all" : {}

},

"fields": []

}

'

The result will contain only the "metadata" of your documents

{

"took" : 7,

"timed_out" : false,

"_shards" : {

"total" : 5,

"successful" : 5,

"failed" : 0

},

"hits" : {

"total" : 4,

"max_score" : 1.0,

"hits" : [ {

"_index" : "index",

"_type" : "type",

"_id" : "36",

"_score" : 1.0

}, {

"_index" : "index",

"_type" : "type",

"_id" : "38",

"_score" : 1.0

}, {

"_index" : "index",

"_type" : "type",

"_id" : "39",

"_score" : 1.0

}, {

"_index" : "index",

"_type" : "type",

"_id" : "34",

"_score" : 1.0

} ]

}

}

For the latter, if you want to include a field from your document, simply add it to the fields array

curl http://localhost:9200/index/type/_search?pretty=true -d '

{

"query" : {

"match_all" : {}

},

"fields": ["document_field_to_be_returned"]

}

'

es查询所欲,检索ElasticSearch中所有_id的高效方法相关推荐

  1. es查询所欲_Elasticsearch基本查询总结

    Elasticsearch是一个分布式文档存储.Elasticsearch不会将信息存储为列数据的行,而是存储已序列化为JSON文档的复杂数据结构.当集群中有多个Elasticsearch节点时,存储 ...

  2. es查询所欲_elasticsearch之查询的两种方式

    前言 简单的没挑战,来点复杂的,比如查看来自顾家的都有哪些人怎么查呢?elasticsearch提供两种查询方式: 查询字符串(query string),简单查询,就像是像传递URL参数一样去传递查 ...

  3. es查询大文本效率_es中terms查询速度能否优化

    es表结构如下:PUT demo/ { "mappings": { "demo": { "_all": { "enabled&qu ...

  4. es查询所欲_ElasticSearch 查询所有数据

    1,分页查询所有,但最多能查10000 条记录,超过就会报错 public List getAll(String index, String type, QueryBuilder queryBuild ...

  5. 在Elasticsearch中查询Term Vectors词条向量信息

    这篇文章有点深度,可能需要一些Lucene或者全文检索的背景.由于我也很久没有看过Lucene了,有些地方理解的不对还请多多指正. 更多内容还请参考整理的ELK教程 关于Term Vectors 额, ...

  6. 【Elasticsearch】在Elasticsearch中查询Term Vectors词条向量信息

    1.概述 转载:https://www.cnblogs.com/xing901022/p/5348737.html 关于Term Vectors 额,对于这个专业词汇,暂且就叫做词条向量吧,因为实在想 ...

  7. Elasticsearch中的Term查询和全文查询

    Elasticsearch中的Term查询和全文查询 前言 Term 查询 exists 查询 fuzzy 查询 ids 查询 prefix 查询 range 查询 regexp 查询 term 查询 ...

  8. ES(三)es查询语法

    一.介绍:语法GET /索引/类型/_search         查询条件,这个查询条件有两种写法, 一种是在GET的url中指定参数:这种方法比较简单,如查询所有 GET /wtyy-test/u ...

  9. 【236期】ElasticSearch 进阶:一文全览各种 ES 查询在 Java 中的实现

    点击上方"Java精选",选择"设为星标" 别问别人为什么,多问自己凭什么! 下方有惊喜,留言必回,有问必答! 每天 08:15 更新文章,每天进步一点点... ...

最新文章

  1. ios html cookies,iOS-WKWebView携带cookie发送http请求,cookie失效
  2. 实现一个域名对应多个IP地址和DNS优缺点详解!
  3. oracle故障级别划分,jfinal 2.2 oracle 事务级别问题
  4. CodeSmith 4.0 正式版发布
  5. centos 管道符取第一行_Linux用户组管理及用户权限及管道符应用
  6. 带注释源码php,php的注释方法
  7. matlab程序 surf算法,【求大神帮忙,surf算法源代码解析】
  8. 一篇文章搞懂filebeat(ELK)
  9. 30篇记录==一个月了~
  10. 安装vs2013以后,链接数据库总是报内存损坏,无法写入的错误
  11. Chrome离线安装包下载方式
  12. java set retainall_Java的Set集合中的retainAll()方法
  13. 这8款数据恢复软件你见过吗?数据恢复软件推荐
  14. 技术美术知识学习4200:SSAO算法
  15. Android各个版本的Feature变更
  16. 阿里云域名注册+服务器购买+备案教程
  17. LeetCode——反转链表
  18. 妙用自定义注解,一行代码搞定大功能(文末赠书)
  19. 谷歌优化效果怎么样?外贸如何做好谷歌SEO优化排名?
  20. UART、RS232、RS485和RS422

热门文章

  1. 我的电子游戏之旅--机械迷城
  2. LeetCode - 环形链表
  3. linux aws mysql5.7安装
  4. 我花了15天认真总结了各行各业几百位粉丝的问题(总结:如何才能使自己更优秀?)
  5. 旅通软件:旅游管理系统是用?还是不用?
  6. 天猫9月上旬规则变动合集
  7. 广点通屡次改版,微信“电商化”缺什么?
  8. 解决libresource_retriever.so:对‘curl_easy_init@CURL_OPENSSL_3’未定义的引用
  9. 小学计算机教资报名科目,小学教资考试科目
  10. 数据可视化之箱线图详解