Elasticsearch river-jdbc used
Elasticsearch river-jdbc used
mysql-table
CREATE TABLE user (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(200) COLLATE utf8_bin NOT NULL,
login_name varchar(200) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
insert into user values(null, 'hanmei', 'hm');
建立索引
curl -u username:passwd -X PUT http://node01:9200/index_testdb01 -d'{ "mappings": { "user": { "properties": { "id": { "type": "long" }, "name": { "index": "not_analyzed", "type": "string" }, "login_name": { "index": "not_analyzed", "type": "string" } } } }}'
同步数据
curl -XPUT 'http://localhost:9200/_river/testdb01/_meta' -d '{ ## 注意这里,testdb01 是 database-name "type": "jdbc", "jdbc": { "driver": "com.mysql.jdbc.Driver", "url": "jdbc:mysql://your-es-ip:3306/testdb01", "user": "your_jdbc_username", "password": "your_jdbc_passwd", "sql": "select id as _id,name,login_name from user", "index": "index_testdb01", "type": "user", "bulk_size": 100, "max_bulk_requests": 30, "bulk_timeout": "10s", "flush_interval": "5s", "schedule": "0 0-59 0-23 ? * *" }}'
Reference article
endymecy.gitbooks.io
github-elasticsearch-jdbc
关键字:elasticsearch
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!