Update docs structure
Original commit: elastic/x-pack-elasticsearch@78277df7fb
This commit is contained in:
parent
c48d2b14dc
commit
af453a3fa4
|
@ -25,10 +25,11 @@ indices and return tabular results. There are four main components:
|
|||
A JDBC driver for Elasticsearch.
|
||||
--
|
||||
|
||||
include::sql-rest.asciidoc[]
|
||||
include::sql-translate.asciidoc[]
|
||||
include::sql-cli.asciidoc[]
|
||||
include::sql-jdbc.asciidoc[]
|
||||
include::sql-query-dsl.asciidoc[]
|
||||
include::sql-overview.asciidoc[]
|
||||
include::sql-getting-started.asciidoc[]
|
||||
include::endpoints/sql-endpoints.asciidoc[]
|
||||
include::functions/sql-functions.asciidoc[]
|
||||
include::language/sql-language.asciidoc[]
|
||||
|
||||
:jdbc-tests!:
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
[role="xpack"]
|
||||
[[sql-cli]]
|
||||
== SQL CLI
|
||||
|
||||
The SQL CLI is a stand alone Java application for quick interaction
|
||||
with X-Pack SQL. You can run it like this:
|
||||
|
||||
["source","bash",subs="attributes,callouts"]
|
||||
--------------------------------------------------
|
||||
$ java -jar cli-{version}.jar
|
||||
--------------------------------------------------
|
||||
|
||||
You can pass the URL of the Elasticsearch instance to connect to as
|
||||
the first parameter:
|
||||
|
||||
["source","bash",subs="attributes,callouts"]
|
||||
--------------------------------------------------
|
||||
$ java -jar cli-{version}.jar https://some.server:9200
|
||||
--------------------------------------------------
|
||||
|
||||
The cli jar is entirely stand alone and can be moved whereever it is
|
||||
needed.
|
||||
|
||||
Once the CLI is running you can use any <<sql-query-dsl,query>> that
|
||||
Elasticsearch supports:
|
||||
|
||||
[source,sqlcli]
|
||||
--------------------------------------------------
|
||||
sql> SELECT * FROM library WHERE page_count > 500 ORDER BY page_count DESC;
|
||||
author | name | page_count
|
||||
----------------------------+-----------------------+---------------
|
||||
Victor Hugo |Les Misérables |1463
|
||||
Miguel De Cervantes Saavedra|Don Quixote |1072
|
||||
Miguel De Cervantes Saavedra|Don Quixote |1072
|
||||
Herman Melville |Moby-Dick or, The Whale|720
|
||||
Charles Dickens |Oliver Twist |608
|
||||
--------------------------------------------------
|
||||
// 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.
|
|
@ -1,31 +0,0 @@
|
|||
[role="xpack"]
|
||||
[[sql-jdbc]]
|
||||
== SQL JDBC
|
||||
|
||||
Elasticsearch's SQL jdbc driver is a fully featured JDBC driver
|
||||
for Elasticsearch. You can connect to it with:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{jdbc-tests}/JdbcIntegrationTestCase.java[connect]
|
||||
--------------------------------------------------
|
||||
<1> The server and port on which Elasticsearch is listening for
|
||||
HTTP traffic. The port is usually 9200.
|
||||
<2> Properties for connecting to Elasticsearch. An empty `Properties`
|
||||
instance is fine for unsecured Elasticsearch.
|
||||
|
||||
To connect to a secured Elasticsearch server the `Properties`
|
||||
should look like:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{security-tests}/JdbcSecurityIT.java[admin_properties]
|
||||
--------------------------------------------------
|
||||
|
||||
Once you have the connection you can use it like any other JDBC
|
||||
connection. For example:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{jdbc-tests}/SimpleExampleTestCase.java[simple_example]
|
||||
--------------------------------------------------
|
|
@ -1,13 +0,0 @@
|
|||
[role="xpack"]
|
||||
[[sql-query-dsl]]
|
||||
== SQL Query DSL
|
||||
|
||||
Content
|
||||
|
||||
Example!
|
||||
|
||||
|
||||
["source","sql",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{sql-spec}/select.sql-spec[wildcardWithOrder]
|
||||
--------------------------------------------------
|
|
@ -1,90 +0,0 @@
|
|||
[role="xpack"]
|
||||
[[sql-rest]]
|
||||
== SQL REST API
|
||||
|
||||
The SQL REST API accepts SQL in a JSON document, executes it,
|
||||
and returns the results. For example:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST /_sql
|
||||
{
|
||||
"query": "SELECT * FROM library ORDER BY page_count DESC",
|
||||
"fetch_size": 5
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[setup:library]
|
||||
|
||||
Which returns:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"columns": [
|
||||
{"name": "author", "type": "keyword"},
|
||||
{"name": "name", "type": "keyword"},
|
||||
{"name": "page_count", "type": "short"},
|
||||
{"name": "release_date", "type": "date"}
|
||||
],
|
||||
"size": 5,
|
||||
"rows": [
|
||||
["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]
|
||||
],
|
||||
"cursor": "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl+v///w8="
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWWWdrRlVfSS1TbDYtcW9lc1FJNmlYdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl\+v\/\/\/w8=/$body.cursor/]
|
||||
|
||||
You can continue to the next page by sending back the `cursor` field:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST /_sql
|
||||
{
|
||||
"cursor": "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8="
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
// TEST[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f\/\/\/w8=/$body.cursor/]
|
||||
|
||||
Which looks like:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"size" : 5,
|
||||
"rows" : [
|
||||
["Dan Simmons", "Hyperion", 482, 612144000000],
|
||||
["Iain M. Banks", "Consider Phlebas", 471, 546134400000],
|
||||
["Neal Stephenson", "Snow Crash", 470, 707356800000],
|
||||
["Robert A. Heinlein", "Starship Troopers", 335, -318297600000],
|
||||
["George Orwell", "1984", 328, 486432000000]
|
||||
],
|
||||
"cursor" : "sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWODRMaXBUaVlRN21iTlRyWHZWYUdrdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl9f///w8="
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWODRMaXBUaVlRN21iTlRyWHZWYUdrdw==:BAFmBmF1dGhvcgFmBG5hbWUBZgpwYWdlX2NvdW50AWYMcmVsZWFzZV9kYXRl9f\/\/\/w8=/$body.cursor/]
|
||||
|
||||
Note that the `column` object is only part of the first page.
|
||||
|
||||
You've reached the last page when there is no `cursor` returned
|
||||
in the results. Like Elasticsearch's <<search-request-scroll,scroll>>,
|
||||
SQL may keep state in Elasticsearch to support the cursor. Unlike
|
||||
scroll, receiving the last page is enough to guarantee that the
|
||||
Elasticsearch state is cleared. For now, that is the only way to
|
||||
clear the state.
|
||||
|
||||
[[sql-rest-fields]]
|
||||
In addition to the `query` and `cursor` fields, the request can
|
||||
contain `fetch_size` and `time_zone`. `fetch_size` is a hint for how
|
||||
many results to return in each page. SQL might chose to return more
|
||||
or fewer results though. `time_zone` is the time zone to use for date
|
||||
functions and date parsing. `time_zone` defaults to `utc` and can take
|
||||
any values documented
|
||||
http://www.joda.org/joda-time/apidocs/org/joda/time/DateTimeZone.html[here].
|
|
@ -1,48 +0,0 @@
|
|||
[role="xpack"]
|
||||
[[sql-translate]]
|
||||
== SQL Translate API
|
||||
|
||||
The SQL Translate API accepts SQL in a JSON document and translates it
|
||||
into native Elasticsearch queries. For example:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST /_sql/translate
|
||||
{
|
||||
"query": "SELECT * FROM library ORDER BY page_count DESC",
|
||||
"fetch_size": 10
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[setup:library]
|
||||
|
||||
Which returns:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"size" : 10,
|
||||
"docvalue_fields" : [
|
||||
"author",
|
||||
"name",
|
||||
"page_count",
|
||||
"release_date"
|
||||
],
|
||||
"sort" : [
|
||||
{
|
||||
"page_count" : {
|
||||
"order" : "desc"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE
|
||||
|
||||
Which is the request that SQL will run to provide the results.
|
||||
In this case, SQL will use the <<search-request-scroll,scroll>>
|
||||
API. If the result contained an aggregation then SQL would use
|
||||
the normal <<search-request-body,search>> API.
|
||||
|
||||
The request body accepts all of the <<sql-rest-fields,fields>> that
|
||||
the <<sql-rest,SQL REST API>> accepts except `cursor`.
|
Loading…
Reference in New Issue