使用 shuf 来打乱一个文件中的行或是选择文件中一个随机的行。

logstah-input-jdbc无法同步到es已经建立的索引中

Logstash | 作者 nbhtm2018 | 发布于2018年02月28日 | 阅读数:2491

ES我现建立一个索引
$ curl -X PUT 'localhost:9200/test' -d '
{
"mappings": {
"jdbc": {
"properties": {
"title": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}
}
}
}'
然后通过logstah-input-jdbc同步到es
配置如下
input {
stdin {
}
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/test"

jdbc_user => "root"
jdbc_password => "123"

jdbc_driver_library => "/home/nbhtm/logstash-6.2.1/mysql-connector-java-5.1.45-bin.jar"
# mysql的Driver
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"

statement => "select id,title from boc_house"
schedule => "* * * * *"
#索引的类型
type => "jdbc"
}
}

filter {
json {
source => "message"
remove_field => ["message"]
}
}

output {
elasticsearch {
hosts => "127.0.0.1:9200"
# index名
index => "test"
# 需要关联的数据库中有有一个id字段,对应索引的id号
document_id => "%{id}"
}
stdout {
codec => json_lines
}
}
数据导入不进去!
直接导入可以写入,但是搜索时候只能通过 text (index)搜索 加了 jdbc(type)就不行   ~~刚入坑 小白
已邀请:

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自: qjdhbdj

不知道是不是es6.x只支持一个索引type的原因,你排查下index下是否已经建立了type了

nbhtm2018

赞同来自:

我搜索出来的结果是 
{"_index":"test","_type":"doc","_id":"23367","_score":6.089664,"_source":{"id":23367,"type":"jdbc","@version":"1","title":"密林","@timestamp":"2018-03-02T07:33:01.761Z"}

这里的_type为什么是doc 而数据里的tpye jdbc
 

要回复问题请先登录注册