SQL: Basic REST spec and tests (elastic/x-pack-elasticsearch#3128)

Adds a basic REST spec and tests for the SQL and translate endpoints so
that clients can can execute these endpoints. We'll keep our complex
REST testing in Java REST tests though.

relates elastic/x-pack-elasticsearch#3115

Original commit: elastic/x-pack-elasticsearch@c5de301f3d
This commit is contained in:
Nik Everett 2017-11-27 14:57:12 -05:00 committed by GitHub
parent 626e9b87a1
commit 378abf1d8f
4 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,16 @@
{
"xpack.sql": {
"documentation": "Execute SQL",
"methods": [ "POST", "GET" ],
"url": {
"path": "/_sql",
"paths": [ "/_sql" ],
"parts": {},
"params": {}
},
"body": {
"description" : "Use the `query` element to start a query. Use the `cursor` element to continue a query.",
"required" : true
}
}
}

View File

@ -0,0 +1,16 @@
{
"xpack.sql.translate": {
"documentation": "Translate SQL into Elasticsearch queries",
"methods": [ "POST", "GET" ],
"url": {
"path": "/_sql/translate",
"paths": [ "/_sql/translate" ],
"parts": {},
"params": {}
},
"body": {
"description" : "Specify the query in the `query` element.",
"required" : true
}
}
}

View File

@ -0,0 +1,29 @@
---
"Execute some SQL":
- do:
bulk:
refresh: true
body:
- index:
_index: test
_type: doc
_id: 1
- str: test1
int: 1
- index:
_index: test
_type: doc
_id: 2
- str: test2
int: 2
- do:
xpack.sql:
body:
query: "SELECT * FROM test ORDER BY int asc"
- match: { columns.0.name: int }
- match: { columns.1.name: str }
- match: { rows.0.0: 1 }
- match: { rows.0.1: test1 }
- match: { rows.1.0: 2 }
- match: { rows.1.1: test2 }

View File

@ -0,0 +1,29 @@
---
"Translate SQL":
- do:
bulk:
refresh: true
body:
- index:
_index: test
_type: doc
_id: 1
- str: test1
int: 1
- do:
xpack.sql.translate:
body:
query: "SELECT * FROM test ORDER BY int asc"
- match:
$body:
size: 1000
_source:
includes:
- str
excludes: []
docvalue_fields:
- int
sort:
- int:
order: asc