用logstash-input-jdbc插件同步postgresql数据库表到elasticsearch中!设置索引类型失效,全部成了doc索引类型
下面的是我的jdbc.conf配置
input {
stdin {
}
jdbc {
# 数据库
jdbc_connection_string => "jdbc:postgresql://localhost:5432/story"
# 用户名密码
jdbc_user => "tzdr"
jdbc_password => "1225"
# 数据库驱动jar包的位置
jdbc_driver_library => "E:/logstash-6.3.1/bin/postgresql/postgresql-9.4.1212.jar"
# postgresql的Driver
jdbc_driver_class => "org.postgresql.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
#statement_filepath => "E:/logstash-6.3.1/bin/postgresql/jdbc.sql"
statement => "select * from book"
schedule => "* * * * *"
#索引的类型
type => "book"
}
jdbc {
# 数据库
jdbc_connection_string => "jdbc:postgresql://localhost:5432/story"
# 用户名密码
jdbc_user => "tzdr"
jdbc_password => "1225"
# 数据库驱动jar包的位置
jdbc_driver_library => "E:/logstash-6.3.1/bin/postgresql/postgresql-9.4.1212.jar"
# postgresql的Driver
jdbc_driver_class => "org.postgresql.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
#statement_filepath => "E:/logstash-6.3.1/bin/postgresql/jdbc.sql"
statement => "select * from want"
schedule => "* * * * *"
#索引的类型
type => "want"
}
}
filter {
json {
source => "message"
remove_field => ["message"]
}
}
output {
if [type]=="book"{
elasticsearch {
hosts => "127.0.0.1:9200"
# index名
index => "myself"
# 需要关联的数据库中有有一个id字段,对应索引的id号 前面记得要%号
document_id => "%{istrue}"
}
}
if [type]=="want"{
elasticsearch {
hosts => "127.0.0.1:9200"
# index名
index => "myself"
# 需要关联的数据库中有有一个id字段,对应索引的id号 前面记得要%号
document_id => "%{id}"
}
}
stdout {
codec => json_lines
}
}
**************************************
下面是head里面显示的最终结果
第一次来论坛发帖!求各位大神帮帮忙,刚入坑老大交代的任务,谢谢各位大佬了