[ElasticStack系列]es其他api

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/jinzhencs/article/details/78247623

参考官网:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html


1.创建index

PUT http://10.2.1.1:9200/index_of_2017-10-15

{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "index_of_2017-10-15"
}

2.查询index

GET http://10.2.1.1:9200/_cat/indices?v

health status index                                  uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   .kibana                                SFIaLg2TRV2ZWXcq148rvA   1   1          9            0     51.9kb         51.9kb
yellow open   applog_all_2017-10-16                  md4v4K0IR1-2A6JG5qMO_Q   3   1          5            0     30.9kb         30.9kb
yellow open   tracelog_all_2017-10-16                p7EzKaBuSSG2ohzrtJh0jA   3   1          5            0     23.1kb         23.1kb
yellow open   tracelog_all_2017-10-15                pY3v2HosRV2P2CwI1grlag   3   1          0            0       162b           162b
yellow open   trace_service_reference_all_2017-10-16 Uj8S_ytLR6OgIRQ8XHvu6g   3   1          3            0     12.8kb         12.8kb
yellow open   trace_service_info                     _9re3a6wSd2BE7yjydIwWQ   1   1          4            0      6.8kb          6.8kb

3.查询多个index数据语法

POST http://10.2.1.1:9200/tracelog_all_2017-10-15,tracelog_all_2017-10-16/_search
即用逗号隔开即可

4.查询可用的index

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html
很多情况下,我们会查询多个index,此时如果有一个index不存在,则整个结果也就返回失败,这肯定不合理,因此需要先校验多个index是否都存在,进而排除掉不存在的index,再做查询。

5.分页

http://blog.csdn.net/wild46cat/article/details/64123353
注意一定要有限定条件,from要小于10000(一般的查询也不会10000页,除非是分批次读取数据做操作,那么这种时候则用scroll)

POST xytest/sutdent/_search
{
“from”: 0,
“size”: 2
}

展开阅读全文

没有更多推荐了,返回首页