title: Elasticsearch - Do i need the JDBC driver?
body: <p><strong>Aim</strong></p>
  
  <p>To synchronize my elasticsearch server with new and expired data in my SQL database </p>
  
  <p><strong>Issue</strong></p>
  
  <p>There are two very different ways I can achieve this and I don't know which is better. I can either <strong>pull</strong> information to elasticsearch with a direct connection to the SQL database using the JDBC river plugin. Alternatively I can <strong>push</strong> data to elasticsearch using the PHP client using the code shown below as an example:</p>
  
  <pre><code>// The Id of the document
  $id = 1;
  
  // Create a document
  $tweet = array(
      'id'      =&gt; $id,
      'user'    =&gt; array(
          'name'      =&gt; 'mewantcookie',
          'fullName'  =&gt; 'Cookie Monster'
      ),
      'msg'     =&gt; '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'  =&gt; '1238081389',
      'location'=&gt; '41.12,-71.34',
      '_boost'  =&gt; 1.0
  );
  // First parameter is the id of document.
  $tweetDocument = new \Elastica\Document($id, $tweet);
  
  // Add tweet to type
  $elasticaType-&gt;addDocument($tweetDocument);
  
  // Refresh Index
  $elasticaType-&gt;getIndex()-&gt;refresh();
  </code></pre>
  
  <p>I was going to have a cron run every thirty minuets to check for items in my database that not only have an "active" flag but that also do not have an "indexed" flag, that means I need to add them to the index. </p>
  
  <p><strong>QUESTION</strong></p>
  
  <p>Seeing as I have two methods to synchronize data between elasticsearch and mysql in two different ways, what is the advantage and disadvantage of each option. Is there a specific usecase which defines using one over the other? </p>