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常 ...
随机推荐
- 2019 ICPC 上海区域赛总结
2019上海区域赛现场赛总结 补题情况(以下通过率为牛客提交): 题号 标题 已通过代码 通过率 我的状态 A Mr. Panda and Dominoes 点击查看 5/29 未通过 B Prefi ...
- Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array(递推)
题意: 长为 n,由 l ~ r 中的数组成,其和模 3 为 0 的数组数目. 思路: dp[ i ][ j ] 为长为 i,模 3 为 j 的数组数目. #include <bits/stdc ...
- 2020牛客暑期多校训练营(第四场)BCFH
BCFH B. Basic God Problem 题意 给出c和n,求fc(n). 题解 递归到最后 fc 函数肯定等于1,那么就变成了求c被乘了几次,只要找到 x 最多能被分解成多少个数相乘就好了 ...
- 【bzoj 2163】复杂的大门(算法效率--拆点+贪心)
题目:你去找某bm玩,到了门口才发现要打开他家的大门不是一件容易的事-- 他家的大门外有n个站台,用1到n的正整数编号.你需要对每个站台访问一定次数以后大门才能开启.站台之间有m个单向的传送门,通过传 ...
- 牛客小白月赛17 G 区间求和
传送门 题意: 题解: 原本想着使用暴力方法: 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream& ...
- Codeforces Round #547 (Div. 3) F1/2. Same Sum Blocks (Easy/Hard) (贪心,模拟)
题意:有一长度为\(n\)的数组,求最多的区间和相同的不相交的区间的个数. 题解:我们可以先求一个前缀和,然后第一层循环遍历区间的右端点,第二层循环枚举左端点,用前缀和来\(O(1)\)求出区间和,\ ...
- Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi (暴力二进制枚举)
题意:给你一个只含\(+\)和\(-\)的字符串,统计它的加减和,然后再给你一个包含\(+,-,?\)的字符串,其中\(?\)可以表示为\(+\)或\(-\),问有多少种情况使得第二个字符串的加减和等 ...
- AWS注册到连接
1. 注册AWS账号 https://www.cnblogs.com/cmt/p/13912814.html 2.注册完成之后,选择实例 Ubuntu,下载xxx.pem文件,查看实例得到ip 比如我 ...
- C#之抛异常
using System; namespace Demo { class Program { static void Main(string[] args) { try { BLLLayer(); } ...
- Win7下安装IIS
安装IIS 1.控制面板 --> 程序 --> 卸载程序,进入"程序与功能". 2.进入"打开或关闭Window功能". 3.找到"Int ...