| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | [role="xpack"][[sql-cli]]== SQL CLIElasticsearch ships with a script to run the SQL CLI in its `bin` directory:[source,bash]--------------------------------------------------$ ./bin/elasticsearch-sql-cli--------------------------------------------------You can pass the URL of the Elasticsearch instance to connect to asthe first parameter:[source,bash]--------------------------------------------------$ ./bin/elasticsearch-sql-cli https://some.server:9200--------------------------------------------------If security is enabled on your cluster, you can pass the usernameand password in the form `username:password@host_name:port`to the SQL CLI:[source,bash]--------------------------------------------------$ ./bin/elasticsearch-sql-cli https://sql_user:strongpassword@some.server:9200--------------------------------------------------Once the CLI is running you can use any <<sql-spec,query>> thatElasticsearch supports:[source,sqlcli]--------------------------------------------------sql> SELECT * FROM library WHERE page_count > 500 ORDER BY page_count DESC;     author      |        name        |  page_count   | release_date-----------------+--------------------+---------------+---------------Peter F. Hamilton|Pandora's Star      |768            |1078185600000Vernor Vinge     |A Fire Upon the Deep|613            |707356800000Frank Herbert    |Dune                |604            |-144720000000Alastair Reynolds|Revelation Space    |585            |953078400000James S.A. Corey |Leviathan Wakes     |561            |1306972800000--------------------------------------------------// TODO it'd be lovely to be able to assert that this is correct but// that is probably more work then it is worth right now.The jar containing the SQL CLI is a stand alone Java application andthe scripts just launch it. You can move it around to other machineswithout having to install Elasticsearch on them. Without the alreadyprovided script files, you can use a command similar to the followingto start the SQL CLI:[source,bash]--------------------------------------------------$ ./java -jar [PATH_TO_CLI_JAR]/elasticsearch-sql-cli-[VERSION].jar https://some.server:9200--------------------------------------------------or[source,bash]--------------------------------------------------$ ./java -cp [PATH_TO_CLI_JAR]/elasticsearch-sql-cli-[VERSION].jar org.elasticsearch.xpack.sql.cli.Cli https://some.server:9200--------------------------------------------------The jar name will be different for each Elasticsearch version (for example `elasticsearch-sql-cli-7.3.2.jar`),thus the generic `VERSION` specified in the example above. Furthermore,if not running the command from the folder where the SQL CLI jar resides,you'd have to provide the full path, as well.
 |