- 浏览: 146036 次
文章分类
最新评论
-
x_looking:
Client client = new TransportCl ...
ELASTICSEARCH常见问题 -
辣de冷wmyes:
ElasticSearch视频教程百度网盘地址:http:// ...
一、Elasticsearch安装使用教程
另外一篇文章:http://blog.csdn.net/dm_vincent/article/details/41643793
本文介绍Elasticsearch零宕机时间更新索引配置映射内容的方法,包括字段类型、分词器、分片数等。方法原理就是,利用别名机制,给索引配置别名,所有应用程序都通过别名访问索引。重建索引,通过索引原名将原索引导入新建索引。再为新索引配置相同的别名。确认成功导入后,则删掉老索引。实现配置参数更新。
注意:
以下所有操作都是基于一个前提:在建原始索引的时候,给原始索引创建了别名
PUT /my_index_v1 //创建索引 my_index_v1
PUT /my_index_v1/_alias/my_index //设置 my_index为 my_index_v1
1. 原始的索引bank,类型:account,mapping如下
{
"settings": {
"number_of_shards": 5
},
"mappings": {
"account": {
"properties": {
"balance": {
"type": "long"
},
"account_number": {
"type": "long"
},
"email": {
"type": "string"
},
"address": {
"type": "string"
},
"age": {
"type": "long"
},
"state": {
"type": "string"
},
"employer": {
"type": "string"
},
"lastname": {
"type": "string"
},
"gender": {
"type": "string"
},
"firstname": {
"type": "string"
},
"city": {
"type": "string"
}
}
}
}
}
2.新建一个空的索引bak_bak,类型:account,,分片20,balance,account_number,age字段由long改成了string类型,具有最新的、正确的配置
{
"settings": {
"number_of_shards": 20
},
"mappings": {
"account": {
"properties": {
"balance": {
"type": "string"
},
"account_number": {
"type": "string"
},
"email": {
"type": "string"
},
"address": {
"type": "string"
},
"age": {
"type": "string"
},
"state": {
"type": "string"
},
"employer": {
"type": "string"
},
"lastname": {
"type": "string"
},
"gender": {
"type": "string"
},
"firstname": {
"type": "string"
},
"city": {
"type": "string"
}
}
}
}
}
3.使用java API迁移索引,主要配置参数如下:
String searchHost = "192.168.11.51";// 旧索引地址
int searchPort = 9300;// 旧索引端口
String searchIndexName = "bank";// 旧索引名字
String searchType = "account";// 旧索引类型
String newIndexName = "bak_bank";// 新索引名字
String newType = "account";// 新索引类型
// 过滤器根据实际情况来定义,可以有选择性的导出数据,不定义filter的话,就是导出全部数据
String filter = "{ 'query' : {'query_string' : { 'query' : 'text:blup*'} } }"
.replaceAll("'", "\"");
String basicAuthCredentials = "base64_ifrequried=";
boolean withVersion = false;
final int hitsPerPage = 2000;//bulk批量操作的内存页大小,一般1000-2500比较合适
float waitInSeconds = 0.0f;//索引线程休眠时间
// increase if you have lots of things to update
int keepTimeInMinutes = 90;
4.接下来修改alias别名的指向(如果你之前没有用alias来改mapping,纳尼就等着哭吧)
curl -XPOST localhost:8305/_aliases -d '
{
"actions": [
{ "remove": {
"alias": "mybank",
"index": "bank"
}},
{ "add": {
"alias": "mybank",
"index": "bak_bank"
}}
]
}
5.确认导入正常时,将老索引删掉
curl -XDELETE localhost:8303/store_v1
本文介绍Elasticsearch零宕机时间更新索引配置映射内容的方法,包括字段类型、分词器、分片数等。方法原理就是,利用别名机制,给索引配置别名,所有应用程序都通过别名访问索引。重建索引,通过索引原名将原索引导入新建索引。再为新索引配置相同的别名。确认成功导入后,则删掉老索引。实现配置参数更新。
注意:
以下所有操作都是基于一个前提:在建原始索引的时候,给原始索引创建了别名
PUT /my_index_v1 //创建索引 my_index_v1
PUT /my_index_v1/_alias/my_index //设置 my_index为 my_index_v1
1. 原始的索引bank,类型:account,mapping如下
{
"settings": {
"number_of_shards": 5
},
"mappings": {
"account": {
"properties": {
"balance": {
"type": "long"
},
"account_number": {
"type": "long"
},
"email": {
"type": "string"
},
"address": {
"type": "string"
},
"age": {
"type": "long"
},
"state": {
"type": "string"
},
"employer": {
"type": "string"
},
"lastname": {
"type": "string"
},
"gender": {
"type": "string"
},
"firstname": {
"type": "string"
},
"city": {
"type": "string"
}
}
}
}
}
2.新建一个空的索引bak_bak,类型:account,,分片20,balance,account_number,age字段由long改成了string类型,具有最新的、正确的配置
{
"settings": {
"number_of_shards": 20
},
"mappings": {
"account": {
"properties": {
"balance": {
"type": "string"
},
"account_number": {
"type": "string"
},
"email": {
"type": "string"
},
"address": {
"type": "string"
},
"age": {
"type": "string"
},
"state": {
"type": "string"
},
"employer": {
"type": "string"
},
"lastname": {
"type": "string"
},
"gender": {
"type": "string"
},
"firstname": {
"type": "string"
},
"city": {
"type": "string"
}
}
}
}
}
3.使用java API迁移索引,主要配置参数如下:
String searchHost = "192.168.11.51";// 旧索引地址
int searchPort = 9300;// 旧索引端口
String searchIndexName = "bank";// 旧索引名字
String searchType = "account";// 旧索引类型
String newIndexName = "bak_bank";// 新索引名字
String newType = "account";// 新索引类型
// 过滤器根据实际情况来定义,可以有选择性的导出数据,不定义filter的话,就是导出全部数据
String filter = "{ 'query' : {'query_string' : { 'query' : 'text:blup*'} } }"
.replaceAll("'", "\"");
String basicAuthCredentials = "base64_ifrequried=";
boolean withVersion = false;
final int hitsPerPage = 2000;//bulk批量操作的内存页大小,一般1000-2500比较合适
float waitInSeconds = 0.0f;//索引线程休眠时间
// increase if you have lots of things to update
int keepTimeInMinutes = 90;
4.接下来修改alias别名的指向(如果你之前没有用alias来改mapping,纳尼就等着哭吧)
curl -XPOST localhost:8305/_aliases -d '
{
"actions": [
{ "remove": {
"alias": "mybank",
"index": "bank"
}},
{ "add": {
"alias": "mybank",
"index": "bak_bank"
}}
]
}
5.确认导入正常时,将老索引删掉
curl -XDELETE localhost:8303/store_v1
发表评论
-
使用 Scripted Metric Aggregation 遇到的问题
2016-02-19 14:12 2403使用Scripted Metric Aggregation进行 ... -
ElasticSearch性能优化策略
2016-02-17 19:42 3487ElasticSearch性能优化主要分为4个方面的优化。 一 ... -
Elasticsearch 数据建模 - 处理关联关系
2016-02-17 14:40 1021数据建模(Modeling Your Data ... -
数据类型转换错误
2016-02-15 18:28 1554异常: Invalid shift value (64) in ... -
elasticsearch 排序异常,关键字冲突
2016-02-03 12:35 5803org.elasticsearch.action.search ... -
ElasticSearch不同类型下同名字段排序错误
2016-02-03 11:18 1894虽然之前知道elasticsearch不同类型下同名字段要慎用 ... -
ElasticSearch immense term错误
2016-02-02 19:07 2570在使用ElasticSearch的过程中遇到了一个immens ... -
ELASTICSEARCH常见问题
2015-09-22 15:39 31561. ELASTICSEARCH建索引过程中崩溃问题追查 by ... -
routing实例1
2015-09-21 18:51 0package com.eg.part1; import j ... -
routing实例
2015-09-21 18:49 0创建索引: PUT /useraudit_v1 创建索引别名: ... -
elasticsearch 精确,模糊查询实例
2015-09-19 23:55 62517实例 http://www.bubuko.com/infode ... -
elasticsearch java调用实例
2015-09-19 23:55 3498http://outofmemory.cn/code-snip ... -
elasticsearch 的mapping定义
2015-09-18 10:16 1164elasticsearch 的mapping 例子一: 订单 ... -
ElasticSearch基础杂烩-配置-索引-优化
2015-09-19 23:56 600http://blog.csdn.net/huwei2003/ ... -
Elasticsearch安装中文分词插件ik
2015-09-18 10:15 1987安装步骤: 1、到github ... -
ElasticSearch的各种服务的URL
2015-09-18 10:15 492前言 elasticsearch 将各种功能、配置、服务都以A ... -
ElasticSearch集群搭建
2015-09-19 23:56 540http://www.linuxidc.com/Linux/2 ... -
elasticsearch 配置
2015-09-18 10:16 665elasticsearch.conf 主要是设置一些java运 ... -
elasticsearch中文分词集成
2015-09-17 09:35 565elasticsearch官方只提供smartcn这个中文分词 ... -
elasticsearch的Mapping定义
2015-09-17 09:35 1368Mapping,就是对索引库中 ...
相关推荐
lasticsearch整合分词、创建索引、搜索例子,elasticsearch版本为1.0,索引数据从数据表中动态读取生成,有关键字高亮效果,查询分页 1 在dababase目录中导致相关的数据库文件,修改DBCOperation java文件数据库连接...
Spring Boot elasticsearch7.6.2基础操作:创建索引、新增数据、查询数据
Elasticsearch7.0备份索引脚本,配置linux crontab可以自定完成定时备份功能,希望大家给个好评,谢谢
elasticsearch 同义词创建索引实例
对elasticsearch的索引做了一个简单的介绍,可以作为项目培训的课件使用
db-river-es 背景 ,深受欢迎的开源分布式搜索引擎,很多场景下,...定位:从数据库创建ElasticSearch全量索引,索引与数据库数据联动,实时更新 关键词:ElasticSearch index / mysql, sqlserver... / real time i
Elasticsearch-深入理解索引原理
首先,我的索引结构是酱紫的。 ...以上所述是小编给大家介绍的Python中elasticsearch插入和更新数据的实现方法,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
## ElasticSearch ### 概念 - 倒排索引 - 文档:每一条数据就是一个文档 - 词条:由文档分词得到,为词条创建索引 - 查询过程:将用户的搜索内容进行分词,根据词到索引中进行查找 - 与正向索引比较:正向...
elasticsearch.yml 配置文件 ,大自然的搬运工
elasticsearch索引流程,以前的笔记,希望有用
Elasticsearch存储数据之前需要先创建索引,类似于结构型数据库建库建表,创建索引时定义了每个字段的索引方式和数据类型。 常用API: 1、查看指定索引信息: GET http://$user:$passwd@$host:$port/$index 2:...
ElasticSearch数据导出 elasticsearch单文档数据导出 支持自定义查询 导出数据Json文件
文章【elasticsearch】Docker安装elasticsearch配置文件elasticsearch.yml,直接修改ip放入挂载的目录下。
通常,这是通过计划的作业来实现的,该作业从永久性数据存储区(例如MySQL或Postgres)读取数据并将其转换为Elasticsearch索引。 在许多情况下,重建索引需要一个干净的表,以便重建整个索引。 在不中断最终用户...
资源方法有单个的增删改查,模糊查询分页 ,固定字段的模糊查询,所有属性字段的模糊查询
(狂神)ElasticSearch快速入门笔记,ElasticSearch基本操作以及爬虫(Java-ES仿京东实战),包含了小狂神讲的东西,特别适合新手学习,笔记保存下来可以多看看。好记性不如烂笔头哦~,ElasticSearch,简称es,es是一个...
elasticsearch索引安装后所需的网页插件,plugin-head插件,安装下载即可
Elasticsearch 可以用于:分布式实时文件存储,并将每一个字段都编入索引,使其可以被搜索;实时分析的分布式搜索引擎;可以扩展到上百台服务器,处理PB级别的结构化或非结构化数据。 Elasticsearch的文件存储 ...
内容包括9部分 一、 Elasticsearch 简介 简单描述Elasticsearch ...五、Elasticsearch索引和分片 六、索引过程 七、Elasticsearch存储原理 八、Elasticsearch使用过程中的坑 九、Elasticsearch写一致性保障