cli.asciidoc 1.9 KB

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