Sunday 21 May 2017

Elasticsearch jdbc-importer in Nodejs and postgresql

I want to use Elasticsearch within my project. I am using Nodejs and postgresql.

I want to connect postgresql with elasticsearch for this i am using jdbc-importer. I followed the steps written in their docs to connect with postgresql and i succeded in this but through command line.

I want to use jdbc-importer within my project through nodejs

commondline code to run jdbc importer:

bin=/Users/mac/Documents/elasticsearch-jdbc-2.3.4.1/bin
lib=/Users/mac/Documents/elasticsearch-jdbc-2.3.4.1/lib
echo '{
     "type" : "jdbc",
     "jdbc" : {
         "url" : 
        "jdbc:postgresql://localhost:5432/development",
        "sql" : "select * from \"Products\"",
         "index" : "product",
         "type" : "product",
    "elasticsearch" : {
    "cluster" : "elasticsearch",
    "host" : "localhost",
    "port" : 9300
}
     }
 }' | java \
        -cp "${lib}/*" \
        org.xbib.tools.Runner \
        org.xbib.tools.JDBCImporter

above command have created index product in elasticsearch and it also have data from Products table of postgresql.

Now, I want to use that jdbc importer through nodejs and If anyone elso knows other efficient way to manage my postgresql data in elasticsearch they are also welcome to give answere.



via Sam

No comments:

Post a Comment