jprante / elasticsearch-jdbc

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

postgresql: where statement in sql attribute can not be execute. If the sql statement has no where condition,It works well. I am upset with it. Thank you! #576

Open guyajun opened 9 years ago

guyajun commented 9 years ago

!/bin/sh

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" bin=${DIR}/../bin lib=${DIR}/../lib

echo '{ "type" : "jdbc", "jdbc" : { "url" : "jdbc:postgresql://10.200.200.201:5432/cmdbuild", "user":"dbuser", "password":"123456", "sql":"select v.\"Code\" as _id,v.\"Code\" as \"ComputerName\" from \"VirtualServer\" v where v.\"Status\"='A' and v.\"DeviceStatus\"=990", "interval":"5s", "index_settings" : { "index" : { "number_of_shards" : 1, "number_of_replicas":1 } }, "index":"profiles", "type":"Server" } } ' | java \ -cp "${lib}/*" \ -Dlog4j.configurationFile=file://localhost/C:/elasticsearch-jdbc-1.6.0.0-dist/elasticsearch-jdbc-1.6.0.0/bin/log4j2.xml \ org.xbib.tools.Runner \ org.xbib.tools.JDBCImporter

akobler commented 9 years ago

Hi Try this workaround: make a view on your SQL and query that view from the in the "sql"-parameter above.

vaniaravinda commented 9 years ago

TanQ so much @akobler. Solved my issue. I'm having 1 question. After indexing the data without affecting at the time of re-indexing I tried to use aliases but only thing is how can I know the previous alias and removing it and adding the new alias after re-indexing. All this has to happen with a scheduled job. Can u plz provide ur valuable suggestions.