Elasticsearch常用API
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的更多相关文章
- Elasticsearch 常用API
1. Elasticsearch 常用API 1.1.数据输入与输出 1.1.1.Elasticsearch 文档 #在 Elasticsearch 中,术语 文档 有着特定的含义.它是指最顶 ...
- Elasticsearch java api 常用查询方法QueryBuilder构造举例
转载:http://m.blog.csdn.net/u012546526/article/details/74184769 Elasticsearch java api 常用查询方法QueryBuil ...
- Elasticsearch java api 基本搜索部分详解
文档是结合几个博客整理出来的,内容大部分为转载内容.在使用过程中,对一些疑问点进行了整理与解析. Elasticsearch java api 基本搜索部分详解 ElasticSearch 常用的查询 ...
- 搜索引擎Elasticsearch REST API学习
Elasticsearch为开发者提供了一套基于Http协议的Restful接口,只需要构造rest请求并解析请求返回的json即可实现访问Elasticsearch服务器.Elasticsearch ...
- ELK常用API使用方法
以下ELK系列文章参考自http://www.tianyiqingci.com/ 总目录: Monitor API ElasticSearch聚合分析API Elasticsearch信息检索API ...
- Elasticsearch-02-入门:集群、节点、分片、索引及常用API
2. 基础入门 2.1 重要概念 2.1.1 集群和节点 1)cluster Elasticsearch集群是由一个或多个节点组成,通过其集群名称来进行唯一标识.节点在搜索到集群之后,通过判断自身的 ...
- html5 canvas常用api总结(一)
1.监听浏览器加载事件. window.addEventListener("load",eventWindowLoaded,false); load事件在html页面加载结束时发生 ...
- compass General 常用api学习[Sass和compass学习笔记]
compass 中一些常用api 包括一些浏览器hack @import "compass/utilities/general" Clearfix Clearfix 是用来清除浮动 ...
- java基础3.0:Java常用API
本篇介绍Java基础中常用API使用,当然只是简单介绍,围绕重要知识点引入,巩固开发知识,深入了解每个API的使用,查看JavaAPI文档是必不可少的. 一.java.lang包下的API Java常 ...
随机推荐
- Codeforces Round #648 (Div. 2) B. Trouble Sort
一开始读错题了...想当然地认为只能相邻元素交换...(然后换了两种写法WA了4发,5分钟切A的优势荡然无存) 题目链接:https://codeforces.com/contest/1365/pro ...
- 【noi 2.5_8465】马走日(dfs)
最基本的dfs.这代码理应超时的,我也不知为何AC了......打表我都放弃了,因为最大的数据真的要跑很久...... 1 #include<cstdio> 2 #include<c ...
- Codeforces Round #594 (Div. 2) C. Ivan the Fool and the Probability Theory (思维,递推)
题意:给你一个\(n\)x\(m\)的矩阵,需要在这些矩阵中涂色,每个格子可以涂成黑色或者白色,一个格子四周最多只能有\(2\)个和它颜色相同的,问最多有多少种涂色方案. 题解:首先我们考虑一维的情况 ...
- 多线程之ThreadLocal类
深入研究java.lang.ThreadLocal类 0.前言 ThreadLocal(线程变量副本)Synchronized实现内存共享,ThreadLocal为每个线程维护一个本地变量.采用空间换 ...
- vagrant + virtualbox安装centos环境+docker安装
1. 下载vagrant 并安装,安装完成后,输入vagrant回车查看是否安装成功 2. 下载virtualbox.box并安装,安装完成后. 3. 创建虚拟机文件夹,例如.F:/vmimg/fir ...
- LaTex公式在线转图片
Reference https://latex.codecogs.com/gif.latex?THE_FORMULAR 注: 请不要包含空格 或者 将整段url放到浏览器里, 会产生空格等字符的替换, ...
- node.js cli downloader
node.js cli downloader cli 下载器 refs https://github.com/xgqfrms/react-storybook-app xgqfrms 2012-2020 ...
- play games for learning web skills
play games for learning web skills CSS flexbox https://codepip.com/games/flexbox-froggy/ CSS grid ht ...
- node cli & emoji
node cli & emoji cli $ yarn add node-emoji $ npm i node-emoji https://github.com/omnidan/node-em ...
- npx & yarn & npm
npx & yarn & npm React Redux App https://reactjs.org/ https://github.com/facebook/create-rea ...