Skip to content

Commit

Permalink
fix: ES|QL queries no longer require a version (#64)
Browse files Browse the repository at this point in the history
Auto-generated API code
  • Loading branch information
elasticmachine authored May 23, 2024
1 parent 6ce1ff1 commit 24fa939
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 24 deletions.
1 change: 0 additions & 1 deletion docs/reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,6 @@ client.esql.query({ query })
** *`filter` (Optional, { bool, boosting, common, constant_score, dis_max, distance_feature, exists, function_score, fuzzy, geo_bounding_box, geo_distance, geo_polygon, geo_shape, has_child, has_parent, ids, intervals, knn, match, match_all, match_bool_prefix, match_none, match_phrase, match_phrase_prefix, more_like_this, multi_match, nested, parent_id, percolate, pinned, prefix, query_string, range, rank_feature, regexp, rule_query, script, script_score, shape, simple_query_string, span_containing, field_masking_span, span_first, span_multi, span_near, span_not, span_or, span_term, span_within, term, terms, terms_set, wildcard, wrapper, type })*: Specify a Query DSL query in the filter parameter to filter the set of documents that an ES|QL query runs on.
** *`locale` (Optional, string)*
** *`params` (Optional, number | number | string | boolean | null[])*: 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.
** *`version` (Optional, Enum("2024.04.01"))*: The version of the ES|QL language in which the "query" field was written.
** *`format` (Optional, string)*: A short version of the Accept header, e.g. json, yaml.
** *`delimiter` (Optional, string)*: The character to use between values within a CSV row. Only valid for the CSV format.

Expand Down
8 changes: 1 addition & 7 deletions src/api/api/esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class Esql {
async query (this: That, params: T.EsqlQueryRequest | TB.EsqlQueryRequest, options?: TransportRequestOptions): Promise<T.EsqlQueryResponse>
async query (this: That, params: T.EsqlQueryRequest | TB.EsqlQueryRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = []
const acceptedBody: string[] = ['columnar', 'filter', 'locale', 'params', 'query', 'version']
const acceptedBody: string[] = ['columnar', 'filter', 'locale', 'params', 'query']
const querystring: Record<string, any> = {}
// @ts-expect-error
const userBody: any = params?.body
Expand All @@ -63,12 +63,6 @@ export default class Esql {
body = userBody != null ? { ...userBody } : undefined
}

// a version number is required for all ES|QL queries.
// inject a default value if none is provided.
if (typeof body === 'object' && body.version == null) {
body.version = '2024.04.01'
}

for (const key in params) {
if (acceptedBody.includes(key)) {
body = body ?? {}
Expand Down
9 changes: 1 addition & 8 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9646,12 +9646,6 @@ export type EqlSearchResponse<TEvent = unknown> = EqlEqlSearchResponseBase<TEven

export type EqlSearchResultPosition = 'tail' | 'head'

export type EsqlBaseServerlessEsqlVersion = '2024.04.01'

export type EsqlBaseStatefulEsqlVersion = '2024.04.01'

export type EsqlEsqlVersion = '2024.04.01'

export interface EsqlQueryRequest extends RequestBase {
format?: string
delimiter?: string
Expand All @@ -9660,7 +9654,6 @@ export interface EsqlQueryRequest extends RequestBase {
locale?: string
params?: ScalarValue[]
query: string
version?: EsqlEsqlVersion
}

export type EsqlQueryResponse = EsqlColumns
Expand Down Expand Up @@ -10502,7 +10495,7 @@ export interface IndicesStorage {
allow_mmap?: boolean
}

export type IndicesStorageType = 'fs' | '' | 'niofs' | 'mmapfs' | 'hybridfs' | string
export type IndicesStorageType = 'fs' | 'niofs' | 'mmapfs' | 'hybridfs' | string

export interface IndicesTemplateMapping {
aliases: Record<IndexName, IndicesAlias>
Expand Down
9 changes: 1 addition & 8 deletions src/api/typesWithBodyKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9801,12 +9801,6 @@ export type EqlSearchResponse<TEvent = unknown> = EqlEqlSearchResponseBase<TEven

export type EqlSearchResultPosition = 'tail' | 'head'

export type EsqlBaseServerlessEsqlVersion = '2024.04.01'

export type EsqlBaseStatefulEsqlVersion = '2024.04.01'

export type EsqlEsqlVersion = '2024.04.01'

export interface EsqlQueryRequest extends RequestBase {
format?: string
delimiter?: string
Expand All @@ -9817,7 +9811,6 @@ export interface EsqlQueryRequest extends RequestBase {
locale?: string
params?: ScalarValue[]
query: string
version?: EsqlEsqlVersion
}
}

Expand Down Expand Up @@ -10676,7 +10669,7 @@ export interface IndicesStorage {
allow_mmap?: boolean
}

export type IndicesStorageType = 'fs' | '' | 'niofs' | 'mmapfs' | 'hybridfs' | string
export type IndicesStorageType = 'fs' | 'niofs' | 'mmapfs' | 'hybridfs' | string

export interface IndicesTemplateMapping {
aliases: Record<IndexName, IndicesAlias>
Expand Down

0 comments on commit 24fa939

Please sign in to comment.