Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Elastic Search on top of a pre-existing SQL Database?

I've been reading through a lot of good documentation about how to implement Elastic Search on a website with javascript or PHP.

Very good introduction to ES.

Very complete documentation here and here.

A whole CRUD.

Elastic search with PHP: here, here, and here.

So the reason why I'm giving you those URLs is to understand how to use one or many of those great documentations when having a pre-existing SQL DB.

I'm missing the point somewhere: As they said Elasticsearch will create its own indexes and DB with MongoDB, I don't understand how can I use my (gigantic) database using SQL? Let say I have a MySQL DB, and I would like to use Elasticsearch to make my research faster and to propose the user pre-made queries, how do I do that? How does ES works over/along MySQL? How to transfer this gigantic set of Datas (over 8GB) into ES DB in order to be fully efficient at the beginning?

Many Thanks

like image 847
Miles M. Avatar asked Jul 25 '13 11:07

Miles M.


People also ask

Can we use Elasticsearch as primary database?

It is certainly possible to use Elasticsearch as a primary store, when the limitations described are not showstoppers.

Can you query Elasticsearch with SQL?

Use your SQL skills to query data within Elasticsearch, harnessing the power of Elastic with a familiar language. Send your SQL queries via a CLI, REST endpoint, ODBC, or JDBC to get your results with newfound speed.


1 Answers

I am using jdbc-river w/ mysql. It is very fast. You can configure them to continually poll data, or use one-time (one-shot strategy) imports.

e.g.

curl -xPUT http://es-server:9200/_river/my_river/_meta -d ' {     "type" : "jdbc",     "jdbc" : {         "strategy" : "simple",         "poll" : "5s",         "scale" : 0,         "autocommit" : false,         "fetchsize" : 10,         "max_rows" : 0,         "max_retries" : 3,         "max_retries_wait" : "10s",         "driver" : "com.mysql.jdbc.Driver",         "url" : "jdbc:mysql://mysql-server:3306/mydb",         "user" : "root",         "password" : "password*",         "sql" : "select c.id, c.brandCode, c.companyCode from category c"     },     "index" : {         "index" : "mainIndex",         "type" : "category",         "bulk_size" : 30,         "max_bulk_requests" : 100,         "index_settings" : null,         "type_mapping" : null,         "versioning" : false,         "acknowledge" : false     } }' 
like image 167
Tim Avatar answered Sep 19 '22 21:09

Tim