Note:以下API基于ES 5x,6x/7x可能略有不同,具体查看官方文档

ES常用API

# 查看集群node
curl "http://localhost:9200/_cat/nodes?v" # 查看索引
curl "http://localhost:9200/_cat/indices?v"
curl "http://localhost:9200/_cat/indices/api*?v" # 打开一个索引
curl -s -XPOST "http://localhost:9200/my-esdata/_open?pretty" # 关闭一个索引
curl -s -XPOST "http://localhost:9200/my-esdata/_close?pretty" # 删除一个索引
curl -XDELETE "http://localhost:9200/my-esdata" # 设置alias
curl -X POST "localhost:9200/_aliases?pretty" -H 'Content-Type: application/json' -d'
{
"actions" : [
{ "add" : { "index" : "test1", "alias" : "alias1" } }
]
}' # 查看alias
curl "localhost:9200/_cat/aliases?v" # thread
curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
"index.merge.scheduler.max_thread_count" : "1",
"index.translog.flush_threshold_size" : "512m"
}' # 设置副本为0,可快速批量导入
curl -XPUT "localhost:9200/_settings" -d '
{
"index":{
"number_of_replicas":0
}
}' # 关闭合并限流,使导入更快、在导入完成后改回 merge
curl -XPUT "localhost:9200/_cluster/settings" -d '{
"persistent" : {
"indices.store.throttle.type" : "none"
}
}' # 更改threadpool
curl -XPUT "localhost:9200/_cluster/settings" -d '{
"thread_pool": {
"thread_pool.index.size" : "fixed"
"thread_pool.bulk.size" : "32"
"thread_pool.index.queue_size" : "800"
}
}' # 设置刷新频率
PUT /_all/_settings
{
"index" : {
"refresh_interval" : "60s"
}
} # 查看shard分布
curl -XGET "http://localhost:9200/_cat/shards" # 手动移动分片
curl -XPOST "http://localhost:9200/_cluster/reroute" -d '{
"commands" : [ {
"move" :
{
"index" : "my-esdata", "shard" : 3, "from_node" : "localhost", "to_node" : "10.1.1.10"
}
}
]
}'

ES Template API

# 集群设定
curl -XPUT 'http://localhost:9200/_cluster/_settings?preserve_existing=true' -d '{
"index": {
"translog.durability" : "async",
"translog.flush_threshold_size" : "1g",
"translog.sync_interval" : "60s",
"store.throttle.type": "none"
}
}' # 设置全局shards数量
curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
"index": {
"number_of_shards" : "4"
}
}' # 查看所有template基本信息
curl -XGET "http://localhost:9200/_cat/templates?v" # 查看指定template信息
curl -XGET "http://localhost:9200/_template/my-esdata?pretty" # 查看所有template详细信息
curl -XGET "http://localhost:9200/_template?pretty" # 设置my-esdata-template模板
# index name匹配为my-esdata*则使用此template
# template中参数优先与全局参数
curl -XPUT "http://localhost:9200/_template/my-esdata-template" -d '{
"template" : "my-esdata*",
"settings" : {
"number_of_shards" : 4,
"number_of_replicas" : 0,
"refresh_interval" : "60s",
"translog.durability" : "async",
"translog.flush_threshold_size" : "1g",
"translog.sync_interval" : "60s",
"store.throttle.type": "none",
"store.throttle.max_bytes_per_sec": "100m",
"index.routing.allocation.total_shards_per_node": "1"
}
}' # 设置my-test模板
# index name匹配为**则使用此template
# template中参数优先与全局参数
curl -XPUT "http://localhost:9200/_template/my-test-template" -d '{
"template" : "*my-test*",
"settings" : {
"number_of_shards" : 4,
"number_of_replicas" : 0,
"refresh_interval" : "60s",
"translog.durability" : "async",
"translog.flush_threshold_size" : "1g",
"translog.sync_interval" : "60s",
"store.throttle.type": "none",
"store.throttle.max_bytes_per_sec": "100m",
"index.routing.allocation.total_shards_per_node": "1"
}
}'

Elasticsearch常用API的更多相关文章

  1. Elasticsearch 常用API

    1.   Elasticsearch 常用API 1.1.数据输入与输出 1.1.1.Elasticsearch 文档   #在 Elasticsearch 中,术语 文档 有着特定的含义.它是指最顶 ...

  2. Elasticsearch java api 常用查询方法QueryBuilder构造举例

    转载:http://m.blog.csdn.net/u012546526/article/details/74184769 Elasticsearch java api 常用查询方法QueryBuil ...

  3. Elasticsearch java api 基本搜索部分详解

    文档是结合几个博客整理出来的,内容大部分为转载内容.在使用过程中,对一些疑问点进行了整理与解析. Elasticsearch java api 基本搜索部分详解 ElasticSearch 常用的查询 ...

  4. 搜索引擎Elasticsearch REST API学习

    Elasticsearch为开发者提供了一套基于Http协议的Restful接口,只需要构造rest请求并解析请求返回的json即可实现访问Elasticsearch服务器.Elasticsearch ...

  5. ELK常用API使用方法

    以下ELK系列文章参考自http://www.tianyiqingci.com/ 总目录: Monitor API ElasticSearch聚合分析API Elasticsearch信息检索API ...

  6. Elasticsearch-02-入门:集群、节点、分片、索引及常用API

    2. 基础入门 2.1 重要概念 2.1.1 集群和节点 1)cluster Elasticsearch集群是由一个或多个节点组成,通过其集群名称来进行唯一标识.节点在搜索到集群之后,通过判断自身的 ...

  7. html5 canvas常用api总结(一)

    1.监听浏览器加载事件. window.addEventListener("load",eventWindowLoaded,false); load事件在html页面加载结束时发生 ...

  8. compass General 常用api学习[Sass和compass学习笔记]

    compass 中一些常用api 包括一些浏览器hack @import "compass/utilities/general" Clearfix Clearfix 是用来清除浮动 ...

  9. java基础3.0:Java常用API

    本篇介绍Java基础中常用API使用,当然只是简单介绍,围绕重要知识点引入,巩固开发知识,深入了解每个API的使用,查看JavaAPI文档是必不可少的. 一.java.lang包下的API Java常 ...

随机推荐

  1. 自定义 ocelot 中间件输出自定义错误信息

    自定义 ocelot 中间件输出自定义错误信息 Intro ocelot 中默认的 Response 中间件在出错的时候只会设置 StatusCode 没有具体的信息,想要展示自己定义的错误信息的时候 ...

  2. A - A Flipping Game

    这道题判断如何选择区间进行01变换让数列中的1个数最多,可以用暴力做法来做,每选择一个区间求出一个值,最后找到一个最大值. Iahub got bored, so he invented a game ...

  3. Educational Codeforces Round 95 (Rated for Div. 2) B. Negative Prefixes (贪心,构造)

    题意:给你一串长度为\(n\)的序列,有的位置被锁上了,你可以对没锁的位置上的元素任意排序,使得最后一个\(\le0\)的前缀和的位置最小,求重新排序后的序列. 题解:贪心,将所有能动的位置从大到小排 ...

  4. console.dir()可以显示一个对象所有的属性和方法

    console.dir()可以显示一个对象所有的属性和方法 具体方法如下:

  5. MS16-032 windows本地提权

    试用系统:Tested on x32 Win7, x64 Win8, x64 2k12R2 提权powershell脚本: https://github.com/FuzzySecurity/Power ...

  6. 从.NET看微软的焦虑

    节日没事,就像聊聊微软的NET. 1.孩子静悄悄,必定在作妖 截止目前,微软的市值达到1.85万亿美元,按说,这样一个宙斯级的巨无霸应该过的非常舒坦, 但是,和微软市值成鲜明的反差,我们从.NET的发 ...

  7. 23 种设计模式 APP & 23 Design Patterns App

    23 种设计模式 APP & 23 Design Patterns App https://github.com/xgqfrms/23-design-patterns-app https:// ...

  8. Redis in Action : Redis 实战学习笔记

    1 1 1 Redis in Action : Redis  实战学习笔记 1 http://redis.io/ https://github.com/antirez/redis https://ww ...

  9. ECharts Pie All In One

    ECharts Pie All In One 饼图 https://echarts.apache.org/examples/zh/index.html#chart-type-pie 嵌套饼图 http ...

  10. 如何通过 terminal 查看一个文件的 meta信息

    如何通过 terminal 查看一个文件的 meta 信息 Linux shell stat 查看文件 meta 信息 stat stat指令:文件/文件系统的详细信息显示: 使用格式:stat 文件 ...