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

Help importomg data from a stored procedure

Open Trouble123 opened this issue 8 years ago • 1 comments

Hi

i am currently using this great interface to get data from our MS SQL server tables to elasticsearch. I now need to get data from a stored procedure.

First i tried to just copy/paste the code from the https://github.com/jprante/elasticsearch-jdbc page

` { "jdbc" : {

    "url" : "jdbc:mysql://localhost:3306/test",

    "user" : "",

    "password" : "",

    "sql" : [
        {
            "callable" : true,
            "statement" : "{call GET_SUPPLIER_OF_COFFEE(?,?)}",
            "parameter" : [
                 "Colombian"
            ],
            "register" : {
                 "mySupplierName" : { "pos" : 2, "type" : "varchar" }
            }
        }
    ],
    "index" : "my_jdbc_index",
    "type" : "my_jdbc_type"
}

} `

and i get this:

`SettingsException[Failed to load settings from [args]]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name at [Source:
{ "type":"jdbc", { "jdbc" : { "url" : "jdbc:mysql://localhost:3306/test", "user" : "", "password" : "", "sql" : [ { "callable" : true, "statement" : "{call GET_SUPPLIER_OF_COFFEE}", "parameter" : [ "Colombian" ], "register" : { "mySupplierName" : { "pos" : "2", "type" : "varchar" } } } ], "index" : "my_jdbc_index", "type" : "my_jdbc_type" } } }

; line: 4, column: 2]]; at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1083) at org.xbib.tools.JDBCImporter.run(JDBCImporter.java:121) at org.xbib.tools.Runner.main(Runner.java:28) Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name at [Source:
{ "type":"jdbc", { "jdbc" : { "url" : "jdbc:mysql://localhost:3306/test", "user" : "", "password" : "", "sql" : [ { "callable" : true, "statement" : "{call GET_SUPPLIER_OF_COFFEE}", "parameter" : [ "Colombian" ], "register" : { "mySupplierName" : { "pos" : "2", "type" : "varchar" } } } ], "index" : "my_jdbc_index", "type" : "my_jdbc_type" } } }

; line: 4, column: 2] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1581) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:533) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:462) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1516) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:624) at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:53) at org.elasticsearch.common.settings.loader.XContentSettingsLoader.serializeObject(XContentSettingsLoader.java:99) at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:67) at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:45) at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1080) ... 2 more `

i then thought i would try the code from https://github.com/jprante/elasticsearch-jdbc/issues/144 and merge it into what we have for our table queries, but go this: `echo '
{ "type":"jdbc",
"jdbc" : { "driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver", "url":"jdbc:sqlserver://10.253.254.121:1433;databaseName=Leo", "user":"USER", "password":"PASSWORD", "index" : "my_jdbc_river10", "type" : "jdbc", "sql" : { "statement" : "{exec dbo.OpenNext @userId = '"'"'59F8EAF8-F60F-48D0-8D42-32084A8D8F03'"'"', @LocationId = NULL, @IsOnsite = NULL}", "callable" : true } } }

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

`

If anyone can point me to the right direction as to where my issue is, would greatly appreciate it.

Trouble123 avatar Sep 08 '16 04:09 Trouble123

Hi, can anyone help?

Thanks

Trouble123 avatar Sep 19 '16 11:09 Trouble123