jprante / elasticsearch-jdbc

JDBC importer for Elasticsearch
Apache License 2.0
2.84k stars 709 forks source link

Is there any problem at adding interval or schedule property in bat on windows? #851

Open leelyliu opened 8 years ago

leelyliu commented 8 years ago

It's OK to run a bat file not "interval" or "schedule". But I need to import data every 1 minutes for a test. But after add "interval" to the bat file, the console show as following:

D:\Download\elasticsearch-jdbc-2.3.3.1\bin>mysql-interval.bat { "type" : "datatest", "jdbc" : { "url" : "jdbc:mysql://localhost:3306/test", "user" : "xxx", "password" : "xxx", "sql" : "select *, dataId as _id from datate st", "treat_binary_as_string" : true, "elasticsearch" : { "cluster" : "elasticsearch", "host" : "localhost", " port" : 9300 },"interval" : "1m",^ '"index"' not internal or external command, not runnable program or batch file. '}}' not internal or external command, not runnable program or batch file.

D:\Download\elasticsearch-jdbc-2.3.3.1\bin>mysql-interval.bat { "type" : "datatest", "jdbc" : { "url" : "jdbc:mysql://localhost:3306/test", "user" : "xxx", "password" : "xxx", "sql" : "select , dataId as _id from datate st", "treat_binary_as_string" : true, "elasticsearch" : { "cluster" : "elasticsearch", "host" : "localhost", " port" : 9300 },"schedule": "0 0-59 0-23 ? * ",^ '"index"' not internal or external command, not runnable program or batch file.

the bat file is:

@echo off

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

REM ???
echo {^
    "type" : "datatest",^
    "jdbc" : {^

        "url" : "jdbc:mysql://localhost:3306/test",^
        "user" : "xxx",^
        "password" : "xxx",^
"schedule": "0 0-59 0-23 ? * *",^
        "sql" :  "select *, dataId as _id from datatest",^
        "treat_binary_as_string" : true,^
        "elasticsearch" : {^
             "cluster" : "elasticsearch",^
             "host" : "localhost",^
             "port" : 9300^
        },^
        "index" : "test3"^     
 }^
}^ | "%JAVA_HOME%\bin\java" -cp "%LIB%" -Dlog4j.configurationFile="%BIN%\log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"

I feel puzzle. What's wrong in the file?

Thanks!

leelyliu commented 8 years ago

I am using elasticsearch-jdbc 2.3.3.1 and elasticsearch 2,3,3.

jinyidong commented 8 years ago

{"type" : "jdbc",^ "jdbc" : {^ "url" : "jdbc:sqlserver://_;DatabaseName=_",^ "user" : "",^ "password" : "**",^ "sql" : "select Id as id,* from ",^ "treat_binary_asstring" : true,^ "elasticsearch" : {^ "cluster" : "elasticsearch",^ "host" : "localhost",^ "port" : 9300^ },^ "index" : "**",^ "type" : "***",^ "strategy":"simple",^ "interval":0,^ "flush_inerval":"5s",^ "schedule" : "0 0/1 0-23 ? * "^ }