Reputation: 337
I recently started looking ElasticSearch to implement search in my application. I have my database in Mysql which have approx. >2 mn records. I know in sphinx we could create an index directly on any mysql table column. I wanted to know if its possible in Elasticsearch, if not directly how we could implement that?
Thanks Mohit
Upvotes: 10
Views: 10595
Reputation: 289
You have two options in this case:-
Upvotes: 0
Reputation: 455
Step-1: Download latest version of elastic search
Step-2: After downloading logstasch need to install jdbc plugin
bin/plugin install logstash-input-jdbc
Step-3: Download mysql-jdbc driver...as i downloaded and the file name is mysql-connector-java-5.1.36.jar. put this file inside logstash/drivers/mysql-connector-java-5.1.36.jar ....you can put it anywhere you want. but remember the path.
Step-4: Now create a db.conf file and put it inside logstash directory...in my case logstash-2.3.2/logstash-jdbc.conf here is the content:
Jdbc Input Parameter Description
jdbc_driver_library Full path of jdbc library jdbc_driver_class JDBC driver class to load, for MySQL it is com.mysql.jdbc.Driver jdbc_connection_string JDBC mysql connection string jdbc_user MySQL user jdbc_password MySQL user password schedule Run input statement every minutes. Available scheduling option statement MySQL statement parameters Parameter to pass in MySQL statement
Jdbc Output Parameters Description
Parameter Description
index Elasticsearch Index name
document_type Elasticsearch Index type.
document_id Id of elastic search doc
Step-5: Now set up is complete. we need to start logstart. before that start elasicsearch
then start logstsh and give it jadbc-db.conf file for configuration $ cd logstash-2.3.2 $ bin/logstash agent -f logstash-jdbc.conf
Now test your data quick in elastic search http://localhost:9200/users/users/_search
Thank You Debs
Upvotes: 0
Reputation: 1452
https://github.com/jprante/elasticsearch-river-jdbc does that. You can syncronize data from mysql source, using an "operations table".
It,s a little bit tricky first time installing, but it works.
First you have to install the plugin Second, you have to set up ( configure) the imported data
Upvotes: 4
Reputation: 8949
There is no native support (at this time) for mysql in Elastic Search like there is in Sphinx.
Elastic Search is a great option for search, but you'll have probably to do some custom work to trigger reindexing of items when they change in your database. Exactly how that is accomplished will depend alot on your application. Elastic Search has great near real time search functionality, and has been proven to perform well under heavy indexing load so triggering reindexing shouldn't a concern for most applications.
The NoSQL movement seems to gaining steam as well. Some applications use Elastic Search as the only data store.
Upvotes: 4