Hello again Elasticsearch wizards,
I have what is probably a stupid Java question. I’ve spun up a Docker container of Elasticsearch v7.4.0, and I’m loving the “elasticsearch-sql-cli” script you can use to submit SQL-like queries to ES. Great stuff! The only hitch is, I have to run the script from within the container.
The online documentation (here) says “The jar containing [elasticsearch-sql-cli] is a stand alone Java application and the scripts just launch it. You can move it around to other machines without having to install Elasticsearch on them.” That sounded great. So I copied “elasticsearch-sql-cli,” the Java Jar file, plus two other files that “elasticsearch-sql-cli” referenced. (“elasticsearch-env” and “x-pack-env,” all in
Of course, when transplanted to a remote machine, the script did not work. (Yes, the remote machine can ping the ES Docker container.) I took a look at “elasticsearch-sql-cli,” saw that it statically pointed to the other files in their original file locations, and then edited the script:
#!/bin/bash # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one # or more contributor license agreements. Licensed under the Elastic License; # you may not use this file except in compliance with the Elastic License. source /home/me/es_sql_script/elasticsearch-env source /home/me/es_sql_script/x-pack-env CLI_JAR="/home/me/es_sql_script/elasticsearch-sql-cli-7.4.0.jar" exec \ "$JAVA" \ -jar "$CLI_JAR" \ "$@"
But of course, that didn’t work, either. So I wonder if I’m misunderstanding what the documentation means when it says “You can move it around to other machines.” Am I to just move the jar file and write a Java wrapper program that launches it? Or is it meant to be executed directly from the command line? I (obviously) don’t know much about jar files, but I don’t think Elastic intended either of those as solutions.
Any advice is appreciated.