Elasticsearch - Do I need a JDBC driver?

purpose

To sync my elasticsearch server with new and expired data in my SQL database

Question

There are two different ways to achieve this, and I do not know which is better. I can either pull information into elasticsearch with a direct connection to the SQL database using the JDBC river plugin. Alternatively, I can push data in elasticsearch using a PHP client using the code below:

// The Id of the document
$id = 1;

// Create a document
$tweet = array(
    'id'      => $id,
    'user'    => array(
        'name'      => 'mewantcookie',
        'fullName'  => 'Cookie Monster'
    ),
    'msg'     => 'Me wish there were expression for cookies like there is for apples. "A cookie a day make the doctor diagnose you with diabetes" not catchy.',
    'tstamp'  => '1238081389',
    'location'=> '41.12,-71.34',
    '_boost'  => 1.0
);
// First parameter is the id of document.
$tweetDocument = new \Elastica\Document($id, $tweet);

// Add tweet to type
$elasticaType->addDocument($tweetDocument);

// Refresh Index
$elasticaType->getIndex()->refresh();

I was about to run cron every thirty minutes to check for items in my database that not only have an “active” flag, but also don't have an “indexed” flag, which means I need to add them to the index.

Question

, elasticsearch mysql , . , ?

+4
3

, Elasticsearch, Elasticsearch. .

, - Elasticsearch. , - (, , ). newTweet. , Elasticsearch , .

/ - ( ), (Gearman Beanstalkd ). , Elasticsearch.

, Elasticsearch . cronjob, . ( ) . SQL, , .

, , / - . Elasticsearch , . , ( ). , - SQL .

+2

river, , .

jdbc-river , , 20 . , , elasticsearch.

, , , , .

jdbc-river , . "pull" "push". JVM Elasticsearch. , Elasticsearch .

JSON Elasticsearch.

. , Elasticsearch.

, , . Count API .

, , . , , sql UPDATE, INSERT DELETE.

, , , , .

, , . PHP Elasticsearch ( Elasticseach-php, Elastica FOSElasticaBundle), , , API API Javas API Elasticsearch, .

, - , , ..

: Proof of Concept, API Elastica, 32g RAM, 8 , 2.05 , , . 5 , 10M . , , 20 . , , , , .

, , . , , .

NB: , , , , , , . - , , .

+4

.

:

  • . , .
  • . , .
  • . , sql- ..

:

  • , script , .

:

  • ( )
  • ...

So, as long as you can customize the river to suit your needs, use it . If the river does not support what you want to do, you can stick to your own decision.

0
source

All Articles