ElasticSearch - creating JDBC river

Gul Muhammad Akbari picture Gul Muhammad Akbari · Apr 24, 2014 · Viewed 7.5k times · Source

I working on a PHP project, Using MYSQL for storing data. I want to use ElasticSearch search engine for searching I installed the ES on my Mac OS. I know after that I should create JDBC river but I don't know how. Any body can help me? thanks.

Answer

Roopendra picture Roopendra · Apr 24, 2014

Steps to install Elasticsearch JDBC River Plugin

1) Download and install Elasticsearch
2) Start Elasticsearchby running bin/elasticsearch from the installation directory

3) Install the river-jdbc plugin for Elasticsearch version. You can get jdbc river plugin for your version from here

If you are using elaticssearch version 1.0.0 then your installation command will be

./bin/plugin --install river-jdbc --url http://bit.ly/1gIk4jW

4) Now download the MySQL JDBC driver. The current version is 5.1.30. You can get latest version information from here

5) Copy jar in elasticsearch/plugins/river-jdbc direcory

6) Now Restart elasticsearch from your installation directory bin/elsaticsearch -f

7) Run below command configure jbdc river with your elasticsearch index.

curl -XPUT 'localhost:9200/_river/my_jdbc_river/_meta' -d '{
    "type" : "jdbc",
    "jdbc" : {
        "url" : "jdbc:mysql://localhost:3306/test",
        "user" : "",
        "password" : "",
        "sql" : "select * from yourDBTable",
        "index" : "write_index_name_here",
        "type" : "write_index_type_here"
    }
}'

You can use more parameter as per your need more details about elasticsearch-river-jdbc parameters

8) Now test your plugin is up or not using below command

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