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. 查看文件MD5值

    Windows 打开命令窗口(Win+R),然后输入cmd ·输入命令certutil -hashfile 文件绝对路径 MD5 Linux MD5算法常常被用来验证网络文件传输的完整性,防止文件被人 ...

  2. Watering Grass(贪心算法)

    给定一条草坪.草坪上有n个喷水装置.草坪长l米宽w米..n个装置都有每个装置的位置和喷水半径..要求出最少需要几个喷水装置才能喷满草坪..喷水装置都是装在草坪中间一条水平线上的. n sprinkle ...

  3. HDU-3240(卡特兰数+分解质因数后求逆元)

    卡特兰数相关公式 : \(H_n = {C_{2n}^n \over n+1)}\) \(H_n = {(4n-2)\over n+1}\times H_{n-1}\) \(H_n = C_{2n}^ ...

  4. Educational Codeforces Round 91 (Rated for Div. 2) A. Three Indices

    题目链接:https://codeforces.com/contest/1380/problem/A 题意 给出一个大小为 $n$ 的排列,找出是否有三个元素满足 $p_i < p_j\ and ...

  5. A. Crazy Town

    Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation ...

  6. AcWing 247. 亚特兰蒂斯 (线段树,扫描线,离散化)

    题意:给你\(n\)个矩形,求矩形并的面积. 题解:我们建立坐标轴,然后可以对矩形的横坐标进行排序,之后可以遍历这些横坐标,这个过程可以想像成是一条线从左往右扫过x坐标轴,假如这条线是第一次扫过矩形的 ...

  7. hdu5496 Beauty of Sequence

    Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission ...

  8. Codeforces Round #636div3 D. Constant Palindrome Sum (划分区间,差分)

    题意:给你一个长度为偶数n的数组,每次可以将一个元素修改为不大于k的值,要求每个a[i]+a[n-i+1]都相等,求最少操作多少次 题解:假设每一对的和都为sum,小的记为mn,大的记为mx;     ...

  9. Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum (二进制,前缀和)

    题意:有两个\(01\)字符串\(a\)和\(b\),每次让\(a\)和\(b\)进行与运算,将值贡献给答案,然后将\(b\)右移一位,直到\(b=0\). 题解:因为\(a\)不变,而\(b\)每次 ...

  10. conda 命令笔记

    1.虚拟环境 conda -V # 查看当前conda 版本 conda update conda # 更新conda conda env list 查看当前已有的虚拟环境 conda create ...