cli.asciidoc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[sql-cli]]
  4. == SQL CLI
  5. Elasticsearch ships with a script to run the SQL CLI in its `bin` directory:
  6. [source,bash]
  7. --------------------------------------------------
  8. $ ./bin/elasticsearch-sql-cli
  9. --------------------------------------------------
  10. The jar containing the SQL CLI is a stand alone Java application and
  11. the scripts just launch it. You can move it around to other machines
  12. without having to install Elasticsearch on them.
  13. You can pass the URL of the Elasticsearch instance to connect to as
  14. the first parameter:
  15. [source,bash]
  16. --------------------------------------------------
  17. $ ./bin/elasticsearch-sql-cli https://some.server:9200
  18. --------------------------------------------------
  19. If security is enabled on your cluster, you can pass the username
  20. and password in the form `username:password@host_name:port`
  21. to the SQL CLI:
  22. [source,bash]
  23. --------------------------------------------------
  24. $ ./bin/elasticsearch-sql-cli https://sql_user:strongpassword@some.server:9200
  25. --------------------------------------------------
  26. Once the CLI is running you can use any <<sql-spec,query>> that
  27. Elasticsearch supports:
  28. [source,sqlcli]
  29. --------------------------------------------------
  30. sql> SELECT * FROM library WHERE page_count > 500 ORDER BY page_count DESC;
  31. author | name | page_count | release_date
  32. -----------------+--------------------+---------------+---------------
  33. Peter F. Hamilton|Pandora's Star |768 |1078185600000
  34. Vernor Vinge |A Fire Upon the Deep|613 |707356800000
  35. Frank Herbert |Dune |604 |-144720000000
  36. Alastair Reynolds|Revelation Space |585 |953078400000
  37. James S.A. Corey |Leviathan Wakes |561 |1306972800000
  38. --------------------------------------------------
  39. // TODO it'd be lovely to be able to assert that this is correct but
  40. // that is probably more work then it is worth right now.