2016-11-21 59 views
0

今天我开始研究Elastic Search,在我上一个项目中我已经完成了Solr中的搜索,并且我从mysql导入数据,这很简单。ElasticSearch从mysql导入数据

现在我必须在弹性搜索中做同样的工作,并成功地完成了我已经开始按照"https://github.com/jprante/elasticsearch-jdbc#quick-links"工作的设置,但出现错误。

java.lang.IllegalStateException:从不受支持的版本收到的消息:[2.0.0]最小的兼容版本:5.0.0]

我使用弹性搜索5.0.0版,并使用"wget http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/2.3.4.0/elasticsearch-jdbc-2.3.4.0-dist.zip"这是最大可用版本。

请对此建议。

+0

根据提供的链接,在那里给定矩阵,你可以只使用进口至2.3.4,其中ES版本,您正在使用最新的。 – Kulasangar

+0

@Kulasangar所以如何在5.0.0中做到这一点。 –

+0

只要你想从你的mysql数据库中导入数据到ES中的索引? – Kulasangar

回答

1

您可以在logstash配置中使用jdbc插件,以便将数据上传到您的索引,然后确保您可以根据需要添加调度程序来更新它。

logstash配置看起来是这样的:

input { 
    jdbc { 
    jdbc_driver_library => "/mysql-connector-java-5.1.39-bin.jar" 
    jdbc_driver_class => "com.mysql.jdbc.Driver" 
    jdbc_connection_string => "jdbc:mysql://localhost:3306/database_name" 
    jdbc_user => "root" 
    jdbc_password => "password" 
    schedule => "* * * * *" 
    statement => "select * from table1" 
    type => "table1" 
    } 
} 
output { 
    elasticsearch { 
     index => "testdb" 
     document_type => "%{type}" # <- use the type from each input 
     hosts => "localhost:9200" 
    } 
}