我在弹性搜索索引中从MySQL表中获取了dyanamically数据。为此,我使用了以下链接但未获得propper结果:
我使用了以下代码:
echo '{
"type":"jdbc",
"jdbc":{
"url":"jdbc:mysql://localhost:3306/CDFL",
"user":"root",
"password":"root",
"useSSL":"false",
"sql":"SELECT * FROM event",
"index":"event",
"type":"event",
"autocommit":"true",
"metrics": {
"enabled" : true
},
"elasticsearch" : {
"cluster" : "servercluster",
"host" : "localhost",
"port" : 9300
}
}
}' | java -cp "/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/lib/*" -"Dlog4j.configurationFile=file:////etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/bin/log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"
为了获得解决方案,我使用了以下链接:
ElasticSearch how to integrate with Mysql
https://github.com/jprante/elasticsearch-jdbc
答案 0 :(得分:0)
我得到了这个问题的答案: 在根目录中创建一个名为event.sh的文件,并在该文件中跟随代码
<强> event.sh 强>
curl -XDELETE 'localhost:9200/event'
bin=/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/bin
lib=/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/lib
echo '{
"type":"jdbc",
"jdbc":{
"url":"jdbc:mysql://localhost:3306/CDFL",
"user":"root",
"password":"root",
"useSSL":"false",
"sql":"SELECT * FROM event",
"index":"event",
"type":"event",
"poll" : "6s",
"autocommit":"true",
"metrics": {
"enabled" : true
},
"elasticsearch" : {
"cluster" : "servercluster",
"host" : "localhost",
"port" : 9300
}
}
}' | java -cp "/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/lib/*" -"Dlog4j.configurationFile=file:////etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/bin/log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"
echo "sleeping while importer should run..."
sleep 10
curl -XGET 'localhost:9200/event/_refresh'
并按照以下命令在cmd类型中运行该文件:
sh elasticSearch/event.sh
工作正常