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.
1 Answers
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=*'

- 7,674
- 16
- 65
- 92
-
there is no plugins folder in elasticsearch folder. – Gul Muhammad Akbari Apr 24 '14 at 06:40
-
Which version of elasticsearch you are using? Is `bin` folder there? – Roopendra Apr 24 '14 at 06:47
-
1I think after run `./bin/plugin --install river-jdbc --url http://bit.ly/1gIk4jW` command it will create plugin folder directory parallel to bin. – Roopendra Apr 24 '14 at 07:20
-
What should write instead of "write_index_name_here" and "write_index_type_here"? – Gul Muhammad Akbari Apr 26 '14 at 05:04
-
Your index name and index type. I hope you already create index and type. If you haven't create index then [please see documentations here](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html) – Roopendra Apr 26 '14 at 07:02
-
I did this: 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 orders"},"index":{"index":"jdbc","type","jdbc"}}' – Gul Muhammad Akbari Apr 26 '14 at 07:26
-
But when I run curl -XGET 'localhost:9200/jdbc/_search?pretty&q=*' this, got an error "{"error":"IndexMissingException[[jdbc] missing]","status":404}" – Gul Muhammad Akbari Apr 26 '14 at 07:27
-
Is your elasticsearch running on http://localhost:9200 . if it running perfectly then what is your `index` and `type` name? – Roopendra Apr 26 '14 at 07:33
-
I did according this: http://www.asktoapps.com/import-mysql-data-into-elasticsearch/ – Gul Muhammad Akbari Apr 26 '14 at 08:02
-
I don't know how to create index first? – Gul Muhammad Akbari Apr 26 '14 at 08:03
-
I have MYSQL database by the name test and table is orders, I want to implement this in elasticsearch please help me – Gul Muhammad Akbari Apr 26 '14 at 08:04
-
What is the index type? – Gul Muhammad Akbari Apr 26 '14 at 08:20
-
You can create index type using `curl -XPUT 'http://localhost:9200/orders/order'`. `orders` is name of the index and `order` is your index type. replace index name and type in your jdbc river curl query – Roopendra Apr 26 '14 at 08:41
-
I have done all the steps but elasticsearch is failed to start curl: (7) Failed to connect to localhost port 9200: Connection refused. – truesource Dec 12 '16 at 14:33
-
Please refer this [solution](http://stackoverflow.com/questions/31677563/connection-refused-error-on-elastic-search) – Roopendra Dec 13 '16 at 06:34