Skip to content

Commit 747f812

Browse files
AnaethelionBogdan Pintea
andauthored
Initial version of ES|QL query endpoint (#2354)
* initial version of ESQL query endpoint * Add esql as an import shortcut * Alphabetically reorder body properties * Update specification/esql/query/QueryRequest.ts uppercase CSV Co-authored-by: Bogdan Pintea <[email protected]> * Capitalize acronyms * Remove time_zone for the initial version * Fix naming within the documentation string * Add relevant doc_id links to request and params * Explicitely allow multiple types in the form of FieldValue within params * Add ScalarValue, use it as params for esql.query * Change response type to ArrayBuffer * Add type alias ES|QL response body type for consistency * Remove pragmas from the specification as they only are reachable from snapshot builds --------- Co-authored-by: Bogdan Pintea <[email protected]>
1 parent f4d5312 commit 747f812

File tree

7 files changed

+128
-0
lines changed

7 files changed

+128
-0
lines changed

specification/_doc_ids/table.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ eql-search-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/
121121
eql-sequences,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/eql-syntax.html#eql-sequences
122122
eql-syntax,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/eql-syntax.html
123123
eql,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/eql.html
124+
esql-query,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/esql-rest.html
125+
esql-query-params,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/esql-rest.html#esql-rest-params
124126
evaluate-dfanalytics,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/evaluate-dfanalytics.html
125127
execute-enrich-policy-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/execute-enrich-policy-api.html
126128
expected-reciprocal,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-rank-eval.html#_expected_reciprocal_rank_err

specification/_types/Binary.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919

2020
// Vector tile response
2121
export type MapboxVectorTiles = ArrayBuffer
22+
23+
// ES|QL columns
24+
export type EsqlColumns = ArrayBuffer

specification/_types/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export type FieldValue =
3636
| null
3737
| UserDefinedValue
3838

39+
/**
40+
* A scalar value.
41+
* @codegen_names long, double, string, boolean, null
42+
*/
43+
export type ScalarValue = long | double | string | boolean | null
44+
3945
export class UrlParameter {}
4046

4147
export type Uri = string

specification/esql/_types/Pragmas.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { integer } from '@_types/Numeric'
21+
import { Duration } from '@_types/Time'
22+
23+
export enum DataPartitioning {
24+
SHARD,
25+
SEGMENT,
26+
DOC
27+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RequestBase } from '@_types/Base'
21+
import { QueryContainer } from '@_types/query_dsl/abstractions'
22+
import { Pragmas } from '@esql/_types/Pragmas'
23+
import { ScalarValue } from '@_types/common'
24+
25+
/**
26+
* Executes an ES|QL request
27+
* @rest_spec_name esql.query
28+
* @availability stack since=8.11.0 stability=experimental
29+
* @doc_id esql-query
30+
*/
31+
export interface Request extends RequestBase {
32+
query_parameters: {
33+
/**
34+
* A short version of the Accept header, e.g. json, yaml.
35+
*/
36+
format?: string
37+
/**
38+
* The character to use between values within a CSV row. Only valid for the CSV format.
39+
*/
40+
delimiter?: string
41+
}
42+
/**
43+
* Use the `query` element to start a query. Use `time_zone` to specify an execution time zone and `columnar` to format the answer.
44+
*/
45+
body: {
46+
/**
47+
* By default, ES|QL returns results as rows. For example, FROM returns each individual document as one row. For the JSON, YAML, CBOR and smile formats, ES|QL can return the results in a columnar fashion where one row represents all the values of a certain column in the results.
48+
*/
49+
columnar?: boolean
50+
/**
51+
* Specify a Query DSL query in the filter parameter to filter the set of documents that an ES|QL query runs on.
52+
*/
53+
filter?: QueryContainer
54+
locale?: string
55+
/**
56+
* To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters.
57+
* @doc_id esql-query-params
58+
*/
59+
params?: Array<ScalarValue>
60+
/**
61+
* The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results.
62+
*/
63+
query: string
64+
}
65+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { EsqlColumns } from '@_types/Binary'
21+
22+
export class Response {
23+
body: EsqlColumns
24+
}

specification/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@dangling_indices/*": ["dangling_indices/*"],
2929
"@enrich/*": ["enrich/*"],
3030
"@eql/*": ["eql/*"],
31+
"@esql/*": ["esql/*"],
3132
"@features/*": ["features/*"],
3233
"@fleet/*": ["fleet/*"],
3334
"@graph/*": ["graph/*"],

0 commit comments

Comments
 (0)