0

I have get dyanamically data from MySQL tables in my elasticSearch index. For that i have used following link for but not get propper result:

I have used following code:

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"

and for that get solution i have used following link:

ElasticSearch how to integrate with Mysql

https://github.com/jprante/elasticsearch-jdbc

Fetching changes from table with ElasticSearch JDBC river

https://github.com/logstash-plugins/logstash-input-jdbc

Akash Shrimali
  • 63
  • 3
  • 14

1 Answers1

0

I have got a answer for that question: make one file in root directory called event.sh and following code in that file

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'

and run that file in cmd type following command:

sh elasticSearch/event.sh

that is work fine

Akash Shrimali
  • 63
  • 3
  • 14