2018-06-22 18:40:25 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
2017-12-13 10:19:31 -05:00
|
|
|
[[sql-cli]]
|
|
|
|
== SQL CLI
|
|
|
|
|
2018-05-22 11:33:14 -04:00
|
|
|
Elasticsearch ships with a script to run the SQL CLI in its `bin` directory:
|
2017-12-13 10:19:31 -05:00
|
|
|
|
2017-12-20 13:58:32 -05:00
|
|
|
[source,bash]
|
2017-12-13 10:19:31 -05:00
|
|
|
--------------------------------------------------
|
2018-04-11 11:29:57 -04:00
|
|
|
$ ./bin/elasticsearch-sql-cli
|
2017-12-13 10:19:31 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
|
2017-12-20 13:58:32 -05:00
|
|
|
The jar containing the SQL CLI is a stand alone Java application and
|
|
|
|
the scripts just launch it. You can move it around to other machines
|
2018-05-22 11:33:14 -04:00
|
|
|
without having to install Elasticsearch on them.
|
2017-12-20 13:58:32 -05:00
|
|
|
|
2017-12-13 10:19:31 -05:00
|
|
|
You can pass the URL of the Elasticsearch instance to connect to as
|
|
|
|
the first parameter:
|
|
|
|
|
2017-12-20 13:58:32 -05:00
|
|
|
[source,bash]
|
2017-12-13 10:19:31 -05:00
|
|
|
--------------------------------------------------
|
2018-04-11 11:29:57 -04:00
|
|
|
$ ./bin/elasticsearch-sql-cli https://some.server:9200
|
2017-12-13 10:19:31 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
|
2018-08-31 06:08:32 -04:00
|
|
|
If security is enabled on your cluster, you can pass the username
|
|
|
|
and 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
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2017-12-13 10:19:31 -05:00
|
|
|
Once the CLI is running you can use any <<sql-spec,query>> that
|
|
|
|
Elasticsearch supports:
|
|
|
|
|
|
|
|
[source,sqlcli]
|
|
|
|
--------------------------------------------------
|
|
|
|
sql> SELECT * FROM library WHERE page_count > 500 ORDER BY page_count DESC;
|
2017-12-20 13:58:32 -05:00
|
|
|
author | name | page_count | release_date
|
|
|
|
-----------------+--------------------+---------------+---------------
|
|
|
|
Peter F. Hamilton|Pandora's Star |768 |1078185600000
|
|
|
|
Vernor Vinge |A Fire Upon the Deep|613 |707356800000
|
|
|
|
Frank Herbert |Dune |604 |-144720000000
|
|
|
|
Alastair Reynolds|Revelation Space |585 |953078400000
|
|
|
|
James S.A. Corey |Leviathan Wakes |561 |1306972800000
|
2017-12-13 10:19:31 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
// 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.
|