es常用操作
2024-09-01 17:43:31
1.查看所有索引
_cat/indices?v
2.删除索引
DELETE my_index
3.查询缓存
curl -XGET http://127.0.0.1:9200/my_index/_search?request_cache=true' -d'
4.开启缓存
#配置文件中添加
index.request.cache.enable: true
5.清空缓存
curl -XPOST 'localhost:9200/kimchy,elasticsearch/_cache/clear?request_cache=true'
6.修改index.max_result_window
curl -XPUT http://127.0.0.1:9200/_all/_settings -d '{ "index.max_result_window" :"1000000"}'
7.设置磁盘告警线
curl -XPUT "http://localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"transient": {
"cluster.routing.allocation.disk.watermark.low": "100gb",
"cluster.routing.allocation.disk.watermark.high": "50gb",
"cluster.routing.allocation.disk.watermark.flood_stage": "10gb",
"cluster.info.update.interval": "1m"
}
}'
8.查看文件句柄数量
curl -XGET http://127.0.0.1:9200/_nodes/stats/process?pretty
9.修改索引副本个数
curl -XPUT "http://localhost:9200/my_index/_settings" -H 'Content-Type: application/json' -d'
{
"number_of_replicas": 2
}'
10.修改 refresh 时间
curl -XPUT "http://localhost:9200/index/_settings" -H 'Content-Type: application/json' -d'
{
"refresh_interval”: “10s" }'
11开启慢日志查询
curl -XPUT "http://localhost:9200/index/_settings" -H 'Content-Type: application/json' -d'
{
"index.search.slowlog.threshold.query.warn" : "10s",
"index.search.slowlog.threshold.fetch.debug": "500ms",
"index.indexing.slowlog.threshold.index.info": "5s" }'
集群操作
1.查看集群健康状况
curl -XGET "http://localhost:9200/_cat/health?v"
2.查看集群各节点内存使用情况
curl -XGET "http://localhost:9200/_cat/nodes?v&h=name,port,sm"
3.查看集群节点
curl -XGET "http://localhost:9200/_cat/nodes?v"
4.查看文档数量
curl -XGET "http://localhost:9200/_cat/count?v"
5.查看集群索引
只显示状态为黄色的
curl -XGET "http://localhost:9200/_cat/indices?v&health=yellow"
根据文档降序排列
curl -XGET "http://localhost:9200/_cat/indices?v&s=docs.count:desc"
显示每个索引占用的内存
curl -XGET "http://localhost:9200/_cat/indices?v&h=i,tm&s=tm:desc"
获取每个索引所占用的磁盘空间,按照逆序排列
curl -XGET "http://localhost:9200/_cat/indices?v&h=i,store.size&s=store.size:desc"
6.获取集群的setting
curl -XGET "http://localhost:9200/_cluster/settings"
7.查看集群所在磁盘的分配状况
curl -XGET "http://localhost:9200/_cat/allocation?v"
ES 索引管理
1.创建索引
PUT /xmc_index?pretty
2.添加文档到索引
PUT /xmc_indexa/_doc/1?pretty
{ "name":"xmc"
"phone":"12312312"
}
3.创建索引,设置索引分片数
PUT twitter
{
"settings":{
"index" :{
"number_of_shards":3,
"number_of_replicas":2
} } }
4.创建mapping映射
PUT xmc_indexa
{
"settings":{
"index":{
"number_of_shards":,
"number_of_replicas":
}
},
"mappings":{
"mytype":{
"properties":{
"name":{"type":"text"},
"phone":{"type": "long"}
}
}
}
}
#判断索引是否存在
HEAD xmc_indexa
参考
https://blog.csdn.net/ZYC88888/article/details/91463253
https://www.cnblogs.com/leeSmall/p/9195782.html
https://blog.csdn.net/ifenggege/article/details/86103918 es 查询
最新文章
- 解密jQuery内核 DOM操作
- Android MVP + 泛型,实现了友好VP交互及Activity潜在的内存泄露的优化
- 【转载】jquery validate验证插件,在ajax提交方式下的验证
- 提高安全性而在HTTP响应头中可以使用的各种响应头字段
- linux中执行命令权限不够怎样处理
- Talented Chef(简单题,被我想的太复杂了,用复杂的方法当然会超时咯,由此可见,并非所有题都是想的越多越好)
- Eclipse shift + ctrl + F 不好用
- 与众不同 windows phone (28) - Feature(特性)之手机方向, 本地化, 应用程序的试用体验, 系统主题资源, 本地数据的加密解密
- User-Agent详解
- 使用Dev中的GridView进行数据增删操作
- Windows删除文件时找不到该项目
- 洛谷 [P1341]无序字母对
- python更新数据库脚本两种方法
- SpringBoot的第一个例子
- Saiku控制页面展示的数据过长自动换行(二十四)
- 简明的Python教程当中的几个疑惑点分析#1
- PowerShell 显示气球提示框 1
- Restful levels &;HATEOAS基本介绍~
- Testing - 软件测试的思维和技巧
- WebForm的初步认识
热门文章
- 【JZOJ6214】【20190614】tetris
- 自制Amiibo 踩坑/填坑 指南
- 03-树3 Tree Traversals Again (25 分)
- [西软xms]会员卡消费和余额情况表
- 运行java程序的时候出现Exception in thread ";main"; java.lang.UnsupportedClassVersionError:
- OpenFOAM——冲击斜坡
- 关于python的四舍五入
- [技术博客]React-Native中的组件加载、卸载与setState问题
- js中for..of..的使用和迭代器
- EF获取当天的数据集合