ES操作
2024-09-08 18:56:16
总结一些ES的操作方式及语法
查看健康状态
curl -XGET http://localhost:9200/_cluster/health?pretty
查看索引
curl -XGET http://localhost:9200/_cat/indices?
迁移索引
命令:curl _XPOST 'ES数据库请求地址:9200/_reindex' -d{"source":{"index":"old_index"},"dest":{"index":"new_index"}}
代码:
POST _reindex
{
"source": {
"index": "old_index"
},
"dest": {
"index": "new_index"
}
}
==================================================================================================================
索引别名
一个索引可以接受多个别名,而一个别名也可以映射到多个索引,当指定别名时,别名将自动扩展到添加的索引。别名也可以关联到 filter,然后自动应用到检索,和 routing value。别名不能与索引同名。
添加别名,移除别名示例:
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "test1", "alias" : "alias1" } },
{ "remove" : { "index" : "test1", "alias" : "alias2" } }
]
}
在同一个 API 接口中可以先移除然后添加操作。该操作是原子操作,无需担心别名不指向任何一个索引的短暂瞬间:
POST /_aliases
{
"actions" : [
{ "remove" : { "index" : "test1", "alias" : "alias1" } },
{ "add" : { "index" : "test2", "alias" : "alias1" } }
]
}
过滤器别名
创建过滤器别名,必须要有相应的字段映射。过滤器可以使用 Query DSL 定义,该别名可以用来检索,计数,删除等操作。
PUT /test1
{
"mappings": {
"_doc": {
"properties": {
"user" : {
"type": "keyword"
}
}
}
}
}
Routing
可以将路由值与别名相关联。此功能可以与过滤器别名一起使用,以避免不必要的分片操作。
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "test",
"alias" : "alias1",
"routing" : "1"
}
}
]
}
创建索引的时候指定
curl -X PUT "localhost:9200/logs_20162801" -H 'Content-Type: application/json' -d'
{
"mappings" : {
"_doc" : {
"properties" : {
"year" : {"type" : "integer"}
}
}
},
"aliases" : {
"current_day" : {},
"2016" : {
"filter" : {
"term" : {"year" : 2016 }
}
}
}
}
'
最新文章
- C#----Graphics中部分方法的使用和理解
- CSS3学习笔记--transform基于原始数据(旋转木马实例)
- FlashBuilder 4.7 win64 和 mac版 下载地址
- 用sql的select语句从数据库中获取数据
- QRCode.jar生成二维码
- PHP的数据库 之 关闭问题
- 【我们都爱Paul Hegarty】斯坦福大学IOS8公开组个人笔记28 ScrollView 幻灯片视图
- Activiti-04-.Spring integration
- Mysql语句查询优化
- nginx的基础应用(续)
- ngrx/store effects 使用总结1:计数器
- mysql数据库连接语句一定要加传参的编码格式
- Oracle11g: datetime
- RabbitMQ的学习
- HTML5 WebSocket 协议
- MariaDB:登陆报错:mysqladmin: connect to server at 'localhost' failed
- android TextView 例子代码(文字图片、文字省略、文字滚动)
- Expo大作战(十八)--expo如何发布成独立应用程序,打包成apk或者ipa,发布到对应应用商店
- win10子系统linux.ubuntu开发环境搭建
- linux iostat 性能指标说明(转)
热门文章
- reduced form(简化式)和structural form(结构式)
- react项目--redux封装
- 1. mongodb基础:cursor.forEach使用
- 若依分离版本+Nginx+docker+jenkins 部署
- linux 复合页( Compound Page )的介绍
- 报错:tar: This does not look like a tar archive
- iOS基础 - SceneDelegate
- sqoop mysql2hive
- Linux&;Android相关常用命令汇总记录
- C++内存分配Arena,指的是提前分配的一大块连续内存空间