<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nigilan</title>
    <description>The latest articles on DEV Community by nigilan (@nigilan).</description>
    <link>https://dev.to/nigilan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F176876%2Fe92775a0-0f73-4d39-873f-5c7d977af657.jpg</url>
      <title>DEV Community: nigilan</title>
      <link>https://dev.to/nigilan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nigilan"/>
    <language>en</language>
    <item>
      <title>Migrating Data from Oracle to ElasticSearch</title>
      <dc:creator>nigilan</dc:creator>
      <pubDate>Fri, 08 Nov 2019 05:35:17 +0000</pubDate>
      <link>https://dev.to/nigilan/migrating-data-from-oracle-to-elasticsearch-2o10</link>
      <guid>https://dev.to/nigilan/migrating-data-from-oracle-to-elasticsearch-2o10</guid>
      <description>&lt;p&gt;Environment : Windows &lt;/p&gt;

&lt;h1&gt;
  
  
  Prerequisites
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Installing elasticsearch is very straight forward in Windows. Download the latest version of it and extract it in a folder. &lt;a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-windows.html"&gt;link to download and run Elasticsearch as a service&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In environment variables section, set the JAVA_HOME path. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now, if you go to [&lt;a href="http://localhost:9200/"&gt;http://localhost:9200/&lt;/a&gt;] in the browser, you can see that elasticsearch is running.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install &lt;a href="https://www.elastic.co/guide/en/logstash/current/running-logstash-windows.html"&gt;Logstash&lt;/a&gt; for migrating data from Oracle to Elasticsearch. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To extract the data, make sure your Oracle server is up and running. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Steps for Migration
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Edit the file &lt;strong&gt;logstash-ora.conf&lt;/strong&gt; under config folder in Logstash as below
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input {
 jdbc {
       jdbc_validate_connection =&amp;gt; true
       jdbc_connection_string =&amp;gt; "jdbc:oracle:thin:@192.168.1.2:1521/xe"
       jdbc_user =&amp;gt; "user_details"
       jdbc_password =&amp;gt; "tiger"
       jdbc_driver_library =&amp;gt; "D:\elk\OJDBC-Full\ojdbc7.jar"
       jdbc_driver_class =&amp;gt; "Java::oracle.jdbc.driver.OracleDriver"
       statement =&amp;gt; "select * from search"
   }
}

output {
 elasticsearch {
   hosts =&amp;gt; ["http://localhost:9200"]
   index =&amp;gt; "rawsearchdata"
   #user =&amp;gt; "elastic"
   #password =&amp;gt; "changeme"
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Input
&lt;/h5&gt;

&lt;blockquote&gt;
&lt;p&gt;'jdbc_connection_string' = connection string for Oracle&lt;/p&gt;

&lt;p&gt;'jdbc_user' = schema_name&lt;/p&gt;

&lt;p&gt;'jdbc_driver_library' = path to ojdbc7.jar (OJDBC is freely available for download)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;blockquote&gt;
&lt;p&gt;index = Index where the data is going to get stored&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save the file and run the command &lt;strong&gt;logstash.bat -f ../config/logstash-ora.conf&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once this is done, data will be loaded in the &lt;strong&gt;rawsearchdata&lt;/strong&gt; index&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Check the data
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First of all, lets check the index creation by running this in the browser [&lt;a href="http://localhost:9200/_cat/indices?v"&gt;http://localhost:9200/_cat/indices?v&lt;/a&gt;]&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We should see the &lt;strong&gt;rawsearchdata&lt;/strong&gt; in the list of indices. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now, we can query the elasticsearch using CURL.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X GET "localhost:9200/rawsearchdata/_search" -H 'Content-Type: application/json' -d'
{
   "query": {
       "query_string": {
           "fields": [
               "search_column"
           ],
           "query": "customer data"
       }
   }
}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Pass the column name under the &lt;strong&gt;fields&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thanks for reading... &lt;/p&gt;

</description>
      <category>elasticsearch</category>
      <category>oracle</category>
      <category>migration</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
