elasticsearch-jdbc
elasticsearch-jdbc copied to clipboard
import GROP_CONCAT(JSON_OBJECT not woeking
I'm trying to import from mysql database some rows with joins with other tables as this:
bin=$JDBC_IMPORTER_HOME/bin
lib=$JDBC_IMPORTER_HOME/lib
echo '{
"type" : "jdbc",
"jdbc" : {
"elasticsearch.autodiscover":true,
"elasticsearch.cluster":"elasticsearch",
"url" : "jdbc:mysql://localhost:3306/database",
"user" : "root",
"password" : "123456",
"sql" : [
{
"statement" : "SELECT p.id _id, GROUP_CONCAT(DISTINCT(JSON_OBJECT('product.images[src]',images.src))) as images[]
, p.name FROM products p LEFT JOIN product_images images ON images.product_id=p.id GROUP BY p.id ORDER BY id LIMIT 10",
"parameter" : []
}
],
"index" : "myindex",
"type" : "product",
"elasticsearch": {
"host" : "127.0.0.1",
"port": 9300
}
}
}' | java
-cp "/root/elasticsearch-jdbc-2.3.4.1/lib/*"
-Dlog4j.configurationFile=/root/elasticsearch-jdbc-2.3.4.1/bin/log4j2.xml
org.xbib.tools.Runner \
JDBC Throws an error: [ERROR][org.xbib.elasticsearch.helper.client.BulkTransportClient][elasticsearch[importer][listener][T#1]] bulk [1] failed with 10 failed items, failure message = failure in bulk execution:
Could JDBC works with JSON_OBJECTS?, also i tried to modify the query to other formats like:
SELECT p.id _id, CONCAT("{",GROUP_CONCAT(DISTINCT(JSON_OBJECT('product.images[src]',images.src))),"}") as images[]
, p.name FROM products p LEFT JOIN product_images images ON images.product_id=p.id GROUP BY p.id ORDER BY id LIMIT 10
OR
SELECT p.id _id, CONCAT("{",GROUP_CONCAT(DISTINCT(JSON_OBJECT('images.src',images.src))),"}") as images[]
, p.name FROM products p LEFT JOIN product_images images ON images.product_id=p.id GROUP BY p.id ORDER BY id LIMIT 10
But i get the same error
Thanks for your help, this plugin is awesome!!