Node.js/ElasticSearch:修订间差异
来自康健生活
< Node.js
| 第62行: | 第62行: | ||
Fri, 28 May 2021 11:00:32 GMT | Total Writes: 3455 | Fri, 28 May 2021 11:00:32 GMT | Total Writes: 3455 | ||
Fri, 28 May 2021 11:00:32 GMT | dump complete | Fri, 28 May 2021 11:00:32 GMT | dump complete | ||
</syntaxhighlight>|$|/home/kangkk}} | |||
导入数据,创建索引 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
curl -XPUT http://账号:密码@IP:端口/索引名称</syntaxhighlight>|$|/home/kangkk}} | |||
开始导入 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
./node_modules/elasticdump/bin/elasticdump --input ./索引名称_mapping.json --output http://账号:密码@IP:端口/ --type=mapping | |||
./node_modules/elasticdump/bin/elasticdump --input ./索引名称.json --output http://账号:密码@IP:端口/ --type=data | |||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
2021年5月30日 (日) 11:40的版本
引言
ElasticSearch,文档
服务器安装 elasticsearch 需要依赖 java
/home/kangkk
yum install java -y
[jian@kang /home/kangkk]$
java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
下载并安装 GPG key
/home/kangkk
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
添加 yum 仓库
/home/kangkk
vi /etc/yum.repos.d/elasticsearch.repo
/etc/yum.repos.d/elasticsearch.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
安装 elasticsearch
/home/kangkk
yum install elasticsearch
迁移
elasticdump
/home/kangkk
npm install elasticdump
导出数据
[jian@kang /home/kangkk]$
./node_modules/elasticdump/bin/elasticdump --input http://用户名:密码@IP:端口/索引名称 --output ./索引名称_mapping.json --type=mapping
Fri, 28 May 2021 10:59:42 GMT | starting dump
Fri, 28 May 2021 10:59:42 GMT | got 1 objects from source elasticsearch (offset: 0)
Fri, 28 May 2021 10:59:42 GMT | sent 1 objects to destination file, wrote 1
Fri, 28 May 2021 10:59:42 GMT | got 0 objects from source elasticsearch (offset: 1)
Fri, 28 May 2021 10:59:42 GMT | Total Writes: 1
Fri, 28 May 2021 10:59:42 GMT | dump complete
[jian@kang /home/kangkk]$
./node_modules/elasticdump/bin/elasticdump --input http://用户名:密码@IP:端口/索引名称 --output ./索引名称.json --type=data
Fri, 28 May 2021 11:00:01 GMT | starting dump
Fri, 28 May 2021 11:00:01 GMT | got 100 objects from source elasticsearch (offset: 0)
Fri, 28 May 2021 11:00:01 GMT | sent 100 objects to destination file, wrote 100
Fri, 28 May 2021 11:00:02 GMT | got 100 objects from source elasticsearch (offset: 100)
Fri, 28 May 2021 11:00:02 GMT | sent 100 objects to destination file, wrote 100
...
Fri, 28 May 2021 11:00:32 GMT | sent 55 objects to destination file, wrote 55
Fri, 28 May 2021 11:00:32 GMT | got 0 objects from source elasticsearch (offset: 3455)
Fri, 28 May 2021 11:00:32 GMT | Total Writes: 3455
Fri, 28 May 2021 11:00:32 GMT | dump complete
导入数据,创建索引
/home/kangkk
curl -XPUT http://账号:密码@IP:端口/索引名称
开始导入
/home/kangkk
./node_modules/elasticdump/bin/elasticdump --input ./索引名称_mapping.json --output http://账号:密码@IP:端口/ --type=mapping
./node_modules/elasticdump/bin/elasticdump --input ./索引名称.json --output http://账号:密码@IP:端口/ --type=data
taskrabbit/elasticsearch-dump
error
Error Emitted => {"root_cause":[{"type":"mapper_parsing_exception","reason":"analyzer [ik_smart] not found for field [title]"}],"type":"mapper_parsing_exception","reason":"analyzer [ik_smart] not found for field [title]"}
- 没有安装IK分词器(elasticsearch-analysis-ik)
配置
No categories