总结一些ES的操作方式及语法
 
查看健康状态
 
查看索引
 
迁移索引
命令: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 }
}
}
}
}
'

最新文章

  1. C#----Graphics中部分方法的使用和理解
  2. CSS3学习笔记--transform基于原始数据(旋转木马实例)
  3. FlashBuilder 4.7 win64 和 mac版 下载地址
  4. 用sql的select语句从数据库中获取数据
  5. QRCode.jar生成二维码
  6. PHP的数据库 之 关闭问题
  7. 【我们都爱Paul Hegarty】斯坦福大学IOS8公开组个人笔记28 ScrollView 幻灯片视图
  8. Activiti-04-.Spring integration
  9. Mysql语句查询优化
  10. nginx的基础应用(续)
  11. ngrx/store effects 使用总结1:计数器
  12. mysql数据库连接语句一定要加传参的编码格式
  13. Oracle11g: datetime
  14. RabbitMQ的学习
  15. HTML5 WebSocket 协议
  16. MariaDB:登陆报错:mysqladmin: connect to server at 'localhost' failed
  17. android TextView 例子代码(文字图片、文字省略、文字滚动)
  18. Expo大作战(十八)--expo如何发布成独立应用程序,打包成apk或者ipa,发布到对应应用商店
  19. win10子系统linux.ubuntu开发环境搭建
  20. linux iostat 性能指标说明(转)

热门文章

  1. reduced form(简化式)和structural form(结构式)
  2. react项目--redux封装
  3. 1. mongodb基础:cursor.forEach使用
  4. 若依分离版本+Nginx+docker+jenkins 部署
  5. linux 复合页( Compound Page )的介绍
  6. 报错:tar: This does not look like a tar archive
  7. iOS基础 - SceneDelegate
  8. sqoop mysql2hive
  9. Linux&Android相关常用命令汇总记录
  10. C++内存分配Arena,指的是提前分配的一大块连续内存空间