Open cruzjoey0507 opened 8 years ago
curl XPUT 'localhost:9200/new_elastic/dbajoeyindex' -d ...
is wrong. Where is this documented?? Pass the JSON to the JDBC importer on the CLI with echo
as documented in the bin
directory.
Thanks, but it looks like, yes it doesn't give any error and as well as it doesn't gave any output. I checked the indices and there's no index made under the name of "dbajoeyindex"
I used the command below to check the indices.
curl 'localhost:9200/_cat/indices?v'
[root@es1 elasticsearch-jdbc-1.7.0.1]# cat joey.sh
lib=/root/elasticsearch-jdbc-1.7.0.1/lib bin=/root/elasticsearch-jdbc-1.7.0.1/bin
echo '{ "type" : "mytype", "jdbc" : { "url" : "jdbc:mysql://localhost:3306/master_db", "user" : "XXXX_user", "password" : "XXXXX", "sql" : "SELECT \"dbajoeyindex\" as _index, \"mytype\" as _type, contactid as CID, company_id CompID, first_name as FName, last_name as LName, title as JOB, address, city, state, zip_code, country, county, basedomain, email, phone, phone_direct, fax, employee, revenue, indusrty, email_format, flag, omit, sic, square_footage, dateSent, mark FROM master_db.XXXXX;", "ignore_null_values" : true, "treat_binary_as_string" : false, "elasticsearch" : { "cluster": "XXXXXXX", "host" : "localhost", "autodiscover" : "true", "index" : { "index" : "dbajoeyindex", "type" : "mytype" } } } }' | java -cp "${lib}/*" -Dlog4j.configurationFile=/root/elasticsearch-jdbc-1.7.0.1/bin/log4j2.xml \ org.xbib.tools.Runner \ org.xbib.tools.JDBCImporter [root@ elasticsearch-jdbc-1.7.0.1]#
any thoughts on why I don't have any output?
Check the JDBC importer logs.
I encountered the error that I used a subkect and tried to set the null values to true and binary as string to false, but didn't work. Please help me. I posted the result and the script that I'm using.
root@elasticsearch elasticsearch-jdbc-1.7.0.1]#./joey.sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 725 178 0 178 0 547 808 2483 --:--:-- --:--:-- --:--:-- 0 651 104 104 104 0 547 6234 32789 --:--:-- --:--:-- --:--:-- 32789 org.elasticsearch.common.settings.SettingsException: Failed to load settings from [args] at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:985) at org.xbib.tools.Importer.reader(Importer.java:111) at org.xbib.tools.Importer.reader(Importer.java:57) at org.xbib.tools.Runner.main(Runner.java:28) Caused by: org.elasticsearch.common.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source:
301 Moved Permanently
{"_index":"new_elastic","_type":"dbajoeyindex","_id":"AVQbMZ_LhfgIogHdqDIs","_version":1,"created":true}; line: 1, column: 2] at org.elasticsearch.common.jackson.core.JsonParser._constructError(JsonParser.java:1487) at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:518) at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:447) at org.elasticsearch.common.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1461) at org.elasticsearch.common.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:683) at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:51) at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:60) at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:45) at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:982) ... 3 more root@elasticsearch elasticsearch-jdbc-1.7.0.1]# cat joey.sh
!/bin/bash
JDBC_IMPORTER_HOME=$(dirname $0 )
bin=$JDBC_IMPORTER_HOME/bin lib=$JDBC_IMPORTER_HOME/lib
curl XPUT 'localhost:9200/new_elastic/dbajoeyindex' -d '{ "type" : "mytype", "jdbc" : { "url" : "jdbc:mysql://localhost:3306/master_db", "user" : "XXXXX_user", "password" : "XXXX", "sql" : "select * from master_db.XXXX;", "ignore_null_values" : true, "treat_binary_as_string" : false, "elasticsearch" : { "cluster": "XXXX", "host" : "localhost", "autodiscover" : "true", "index" : { "index" : "dbajoeyindex", "type" : "mytype" } } } }' | java -cp "${lib}/*" -Dlog4j.configurationFile=${bin}/log4j2.xml \ org.xbib.tools.Runner \ org.xbib.tools.JDBCImporter root@elasticsearch elasticsearch-jdbc-1.7.0.1]#