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. 2019 China Collegiate Programming Contest Qinhuangdao Onsite F. Forest Program(DFS计算图中所有环的长度)

    题目链接:https://codeforces.com/gym/102361/problem/F 题意 有 \(n\) 个点和 \(m\) 条边,每条边属于 \(0\) 或 \(1\) 个环,问去掉一 ...

  2. 【51nod1674】区间的价值 V2(算法效率--位运算合并优化+链表实现)

    题目链接:  51nod1674 题意:规定一个区间的价值为这个区间中所有数and起来的值与这个区间所有数or起来的值的乘积.现在l有一个 N 个数的序列,问所有n*(n+1)/2个区间的贡献的和对1 ...

  3. P1280 尼克的任务(DP)

    题目描述 尼克每天上班之前都连接上英特网,接收他的上司发来的邮件,这些邮件包含了尼克主管的部门当天要完成的全部任务,每个任务由一个开始时刻与一个持续时间构成. 尼克的一个工作日为N分钟,从第一分钟开始 ...

  4. ACdream1414 Geometry Problem

    Problem Description       Peter is studying in the third grade of elementary school. His teacher of ...

  5. Codeforces Round #652 (Div. 2)D. TediousLee 推导

    题意: Rooted Dead Bush (RDB) of level 1是只有一个点,如下图 当(RDB) of level i变成(RDB) of level i+1的时候,每一个顶点要进行下面的 ...

  6. 2018-2019 ACM-ICPC, Asia Dhaka Regional Contest C.Divisors of the Divisors of An Integer (数论)

    题意:求\(n!\)的每个因子的因子数. 题解:我们可以对\(n!\)进行质因数分解,这里可以直接用推论快速求出:https://5ab-juruo.blog.luogu.org/solution-p ...

  7. 2019 ICPC Asia Taipei-Hsinchu Regional Problem J Automatic Control Machine (DFS,bitset)

    题意:给你\(m\)个长度为\(n\)的二进制数,求最少选多少个使它们\(|\)运算后所有位置均为\(1\),如果不满足条件,则输出\(-1\). 题解:这题\(n\)的范围很大,所以我们先用\(st ...

  8. 揭秘井井有条的流水线(ZooKeeper 原理篇)

    本文作者:HelloGitHub-老荀 Hi,这里是 HelloGitHub 推出的 HelloZooKeeper 系列,免费开源.有趣.入门级的 ZooKeeper 教程,面向有编程基础的新手. Z ...

  9. spring再学习之注解

    1.使用注解配置spring <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi= ...

  10. freeRTOS V10.0.1移植到STM32F407标准库 - 环境Keil5

    最近因为工作需要用到FreeRTOS,其实开始本人内心是拒绝的因为自己只学习过UCOSIII还没实际上过什么大又复杂的工程,但是谁让FreeRTOS他是Free的呢公司成本考虑肯定是不会选择USOS的 ...