jprante / elasticsearch-jdbc

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

Example scheduled importer script #598

Open doneto opened 9 years ago

doneto commented 9 years ago

Could you please share an example how scheduled script should be run. This is mine:

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

echo '
{
    "type" : "jdbc",
    "jdbc" : {
        "schedule" : "0 0/1 * 1/1 * ? *",
        "url" : "jdbc:mysql://localhost:3306/megadom",
        "user" : "",
        "password" : "",
        "elasticsearch" : {
            "cluster" : "elasticsearch",
            "host" : "localhost",
            "port" : 9300
        },
        "sql" : [
            {
                "statement" : "/var/test.sql"
            }
        ],
        "index" : "myindex",
        "type" : "mytype"
    }
} ' | java \
    -cp "${lib}/*" \
    -Dlog4j.configurationFile=${bin}/log4j2.xml \
    org.xbib.tools.Runner \
    org.xbib.tools.JDBCImporter

When i run it like this ./myscript.sh it works, but there is no output, it just keeps blinking :) Is this normal? i have several more scripts like this and the memory usage concern me...

jprante commented 9 years ago

The script hangs because it waits to be scheduled. Are there any specific reason for running several scripts? You are correct, concurrency is an open issue. I did not expect there are use cases so it has not been on priority.

doneto commented 9 years ago

Well, i use them to feed several ES types with diffrent sql statments on diffrent schedule. But if there is better way...