ElasticSearch常用操作API

基础操作

以下均为[GET]操作

bash 复制代码
查看ElasticSearch全部索引	http://{ip}:9200/_cat/indices?v
查看ElasticSearch集群节点	http://{ip}:9200/_cat/nodes?v
查看ElasticSearch版本信息	http://{ip}:9200/
查看ElasticSearch集群状态	http://{ip}:9200/_cluster/health?pretty
查看ElasticSearch当前主节点	http://{ip}:9200/_cat/master?v
查看ElasticSearch集群指标	http://{ip}:9200/_cluster/stats?pretty
查看ElasticSearch别名信息	http://{ip}:9200/_cat/aliases?v
查看ElasticSearch模板信息	http://{ip}:9200/_cat/templates?v
查看ElasticSearch分配情况	http://{ip}:9200/_cat/allocation?v
查看ElasticSearch文档总数	http://{ip}:9200/_cat/count?v
查看ElasticSearch修复状态	http://{ip}:9200/_cat/recovery?v
查看ElasticSearch分片信息	http://{ip}:9200/_cat/shards?v
查看ElasticSearch挂起任务	http://{ip}:9200/_cluster/pending_tasks?pretty
查看ElasticSearch热线程	    http://{ip}:9200/_nodes/hot_threads?pretty

进阶操作

1.开启、关闭索引通配符删除

false表示可以通配符删除

true表示不可以通配符删除

bash 复制代码
[PUT] _cluster/settings
{
  "transient": {
    "action.destructive_requires_name": false
  }
}

2.调整集群最大分片数

用于配置生命周期后,自动分裂分片使用

bash 复制代码
[PUT] _cluster/settings
{
  "transient": {
    "cluster.max_shards_per_node": 100000
  }
}

3.设置Search返回结果最大条数(默认10000)

bash 复制代码
所有索引生效
[PUT] _all/_settings
{ 
  "index.max_result_window": 50000
}
单个索引生效
[PUT] {index}/_settings
{ 
  "index.max_result_window": 50000
}

4.批量设置索引别名、设置为写索引

同时设置多个在数组里增加即可

"is_write_index": true表示当多个索引共用同一个别名时,设置当前索引为写索引,读的话走别名,可以将所有索引数据都查到

bash 复制代码
[POST] _aliases
{
	"actions": [{
		"add": {
			"index": "m12_insertzone-000001",
			"alias": "m12_insertzone",
			"is_write_index": true
		}
	}]
}

5.设置索引生命周期模板名称及滚动更新索引别名

bash 复制代码
[POST] {index}/_settings
{
	"index.lifecycle.name": "iscas",
	"index.lifecycle.rollover_alias": "m12_insertzone"
}

6.创建索引含配置

bash 复制代码
[PUT] {index}
{
	"aliases": {
		"m12_insertzone": {
			"is_write_index": true
		}
	},
	"settings": {
		"index.number_of_shards": "6",
		"index.number_of_replicas": "1",
		"index.lifecycle.name": "iscas-ilm-policy",
		"index.lifecycle.rollover_alias": "m12_insertzone",
		"index": {
			"routing": {
				"allocation": {
					"require": {
						"hotwarm_type": "hot"
					}
				}
			},
			"translog": {
				"durability": "async",
				"sync_interval": "30s",
				"flush_threshold_size": "1024mb"
			}
		}
	},
	"mappings": {}
}

7. 创建模板含配置

PUT\] _template/{name} ```bash { "index_patterns": ["m22_sample_30-*"], "order": 0, "settings": { "index": { "lifecycle": { "rollover_alias": "m22_sample_30", "name": "iscas-ilm-policy" }, "routing": { "allocation": { "require": { "hotwarm_type": "hot" } } }, "number_of_shards": "6", "number_of_replicas": "1", "translog": { "durability": "async", "sync_interval": "30s", "flush_threshold_size": "1024mb" } } }, "mappings": {} } ```

相关推荐
武子康9 分钟前
大数据-70 Kafka 日志清理:删除、压缩及混合模式最佳实践
大数据·后端·kafka
CCF_NOI.2 小时前
解锁聚变密码:从微观世界到能源新未来
大数据·人工智能·计算机·聚变
杨荧2 小时前
基于Python的电影评论数据分析系统 Python+Django+Vue.js
大数据·前端·vue.js·python
数据智研3 小时前
【数据分享】上市公司创新韧性数据(2007-2023)
大数据·人工智能
辞--忧9 小时前
双十一美妆数据分析:洞察消费趋势与行业秘密
大数据
时序数据说16 小时前
国内时序数据库概览
大数据·数据库·物联网·时序数据库·iotdb
阿Paul果奶ooo18 小时前
Flink中基于时间的合流--双流联结(join)
大数据·flink
数据爬坡ing18 小时前
过程设计工具深度解析-软件工程之详细设计(补充篇)
大数据·数据结构·算法·apache·软件工程·软件构建·设计语言
计算机源码社20 小时前
分享一个基于Hadoop的二手房销售签约数据分析与可视化系统,基于Python可视化的二手房销售数据分析平台
大数据·hadoop·python·数据分析·毕业设计项目·毕业设计源码·计算机毕设选题
Direction_Wind21 小时前
Flinksql bug: Heartbeat of TaskManager with id container_XXX timed out.
大数据·flink·bug