elasticsearch-jdbc icon indicating copy to clipboard operation
elasticsearch-jdbc copied to clipboard

Help! connecting ES & Sql Server

Open medaminenab opened this issue 8 years ago • 1 comments

Hello . iam new to ES so sorry if i say a mistake.

I am trying to connect my database (Sql Server) to ES using the jdbc driver,i have been following this tutorial https://www.supinfo.com/articles/single/2291-mapper-votre-base-donnee-avec-votre-elasticsearch.

i installed ES and it seems working ,but when i try to get data from my database ,I cant find my index.

I put the sql driver into the lib folder, and i change the "mysql-simple-example.bat" :

@echo off

bin=$JDBC_IMPORTER_HOME/bin lib=$JDBC_IMPORTER_HOME/lib echo '{ "type" : "jdbc", "jdbc": {

 "url":"jdbc:sqlserver://localhost:1433;databaseName=Cap",
   
 "user":"amine",
    
 "password":"",
    
 "sql":"select * from dbo.Customer",
    

 "index" : "Cap"
}

}' | java
-cp "${lib}/*"
-Dlog4j.configurationFile=${bin}/log4j2.xml
org.xbib.tools.Runner
org.xbib.tools.JDBCImporter


Iam using windows seven,Es 2.2.0.

Thank you in advance.

medaminenab avatar Feb 09 '17 10:02 medaminenab

@medaminenab Above , i think in "jdbc" : { ..... } you need _type and _id after you need set keywork elasticseach

Sample : @echo off

set DIR=%~dp0 set LIB="%DIR%..\lib*" set BIN="%DIR%..\bin*"

REM ??? echo {^ "type" : "jdbc",^ "jdbc" : {^ "url" : ".....",^ "user" : ".....",^ "password" : ".....",^ "sql" : "SELECT LB.leisure_base_id as _id , * FROM table1 WHERE (condition)",^ "treat_binary_as_string" : true,^ "index":"leisure_bases",^ "type":"leisure_base",^ "elasticsearch" : {^ "cluster" : "elasticsearch",^ "host" : "localhost",^ "port" : 9300^ }^ }^ } | "%JAVA_HOME%\bin\java" -cp "%LIB%" -Dlog4j.configurationFile="%BIN%\log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"

vfa-cuongnv2 avatar Feb 22 '17 03:02 vfa-cuongnv2