Import MySQL data into elasticsearch

There are various ways to import mysql data into elasticsearch. Couple of as follows.

Read one by one record and run curl e.g. curl -XPUT ‘http://localhost:9200/ …
By using JDBC and elasticsearch river.

Using JDBC and Elasticsearch River

Install JDBC river plugin

./bin/plugin -url -install river-jdbc

Download MySQL JDBC driver
cp mysql-connector-java-5.1.21-bin.jar $ES_HOME/plugins/river-jdbc/
./bin/elasticsearch -f

Import table from mysql

curl -XPUT 'localhost:9200/_river/jdbc/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"url" : "jdbc:mysql://localhost:3306/test",
"user" : "",
"password" : "",
"sql" : " select * from test;"
"index" : {
"index" : "jdbc",
"type" : "jdbc"

Select table data from elasticsearch

curl -XGET 'http://localhost:9200/jdbc/_search?q=*'

Display indexed data on browser interface.

bin/plugin -install OlegKunitsyn/elasticsearch-browser

Open http://localhost:9200/_plugin/browser/?database=[index]&table=[type]

Ref. From –

Please note :- Latest elasticsearch has deprecated rivers –

Categories: Elasticsearch, Linux, Website Peformance