Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
950 changes: 741 additions & 209 deletions docs/reference.asciidoc

Large diffs are not rendered by default.

43 changes: 34 additions & 9 deletions src/api/api/async_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import {
Transport,
TransportRequestMetadata,
TransportRequestOptions,
TransportRequestOptionsWithMeta,
TransportRequestOptionsWithOutMeta,
Expand All @@ -44,7 +45,7 @@ export default class AsyncSearch {
}

/**
* Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
* Deletes an async search by identifier. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. If the Elasticsearch security features are enabled, the deletion of a specific async search is restricted to: the authenticated user that submitted the original search request; users that have the `cancel_task` cluster privilege.
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/async-search.html | Elasticsearch API documentation}
*/
async delete (this: That, params: T.AsyncSearchDeleteRequest | TB.AsyncSearchDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchDeleteResponse>
Expand All @@ -66,11 +67,17 @@ export default class AsyncSearch {

const method = 'DELETE'
const path = `/_async_search/${encodeURIComponent(params.id.toString())}`
return await this.transport.request({ path, method, querystring, body }, options)
const meta: TransportRequestMetadata = {
name: 'async_search.delete',
pathParts: {
id: params.id
}
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}

/**
* Retrieves the results of a previously submitted async search request given its ID.
* Retrieves the results of a previously submitted async search request given its identifier. If the Elasticsearch security features are enabled, access to the results of a specific async search is restricted to the user or API key that submitted it.
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/async-search.html | Elasticsearch API documentation}
*/
async get<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params: T.AsyncSearchGetRequest | TB.AsyncSearchGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchGetResponse<TDocument, TAggregations>>
Expand All @@ -92,11 +99,17 @@ export default class AsyncSearch {

const method = 'GET'
const path = `/_async_search/${encodeURIComponent(params.id.toString())}`
return await this.transport.request({ path, method, querystring, body }, options)
const meta: TransportRequestMetadata = {
name: 'async_search.get',
pathParts: {
id: params.id
}
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}

/**
* Retrieves the status of a previously submitted async search request given its ID.
* Get async search status Retrieves the status of a previously submitted async search request given its identifier, without retrieving search results. If the Elasticsearch security features are enabled, use of this API is restricted to the `monitoring_user` role.
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/async-search.html | Elasticsearch API documentation}
*/
async status (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchStatusResponse>
Expand All @@ -118,19 +131,25 @@ export default class AsyncSearch {

const method = 'GET'
const path = `/_async_search/status/${encodeURIComponent(params.id.toString())}`
return await this.transport.request({ path, method, querystring, body }, options)
const meta: TransportRequestMetadata = {
name: 'async_search.status',
pathParts: {
id: params.id
}
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}

/**
* Executes a search request asynchronously.
* Runs a search request asynchronously. When the primary sort of the results is an indexed field, shards get sorted based on minimum and maximum value that they hold for that field, hence partial results become available following the sort criteria that was requested. Warning: Async search does not support scroll nor search requests that only include the suggest section. By default, Elasticsearch doesn’t allow you to store an async search response larger than 10Mb and an attempt to do this results in an error. The maximum allowed size for a stored async search response can be set by changing the `search.max_async_search_response_size` cluster level setting.
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/async-search.html | Elasticsearch API documentation}
*/
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchSubmitResponse<TDocument, TAggregations>, unknown>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchSubmitResponse<TDocument, TAggregations>>
async submit<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>> (this: That, params?: T.AsyncSearchSubmitRequest | TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions): Promise<any> {
const acceptedPath: string[] = ['index']
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'ext', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'min_score', 'post_filter', 'profile', 'query', 'rescore', 'script_fields', 'search_after', 'size', 'slice', 'sort', '_source', 'fields', 'suggest', 'terminate_after', 'timeout', 'track_scores', 'version', 'seq_no_primary_term', 'stored_fields', 'pit', 'runtime_mappings', 'stats']
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'ext', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'knn', 'min_score', 'post_filter', 'profile', 'query', 'rescore', 'script_fields', 'search_after', 'size', 'slice', 'sort', '_source', 'fields', 'suggest', 'terminate_after', 'timeout', 'track_scores', 'version', 'seq_no_primary_term', 'stored_fields', 'pit', 'runtime_mappings', 'stats']
const querystring: Record<string, any> = {}
// @ts-expect-error
const userBody: any = params?.body
Expand Down Expand Up @@ -170,6 +189,12 @@ export default class AsyncSearch {
method = 'POST'
path = '/_async_search'
}
return await this.transport.request({ path, method, querystring, body }, options)
const meta: TransportRequestMetadata = {
name: 'async_search.submit',
pathParts: {
index: params.index
}
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}
}
11 changes: 9 additions & 2 deletions src/api/api/bulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import {
Transport,
TransportRequestMetadata,
TransportRequestOptions,
TransportRequestOptionsWithMeta,
TransportRequestOptionsWithOutMeta,
Expand All @@ -38,7 +39,7 @@ import * as TB from '../typesWithBodyKey'
interface That { transport: Transport }

/**
* Allows to perform multiple index/update/delete operations in a single request.
* Bulk index or delete documents. Performs multiple indexing or delete operations in a single API call. This reduces overhead and can greatly increase indexing speed.
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html | Elasticsearch API documentation}
*/
export default async function BulkApi<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.BulkRequest<TDocument, TPartialDocument> | TB.BulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptionsWithOutMeta): Promise<T.BulkResponse>
Expand Down Expand Up @@ -72,5 +73,11 @@ export default async function BulkApi<TDocument = unknown, TPartialDocument = un
method = 'POST'
path = '/_bulk'
}
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
const meta: TransportRequestMetadata = {
name: 'bulk',
pathParts: {
index: params.index
}
}
return await this.transport.request({ path, method, querystring, bulkBody: body, meta }, options)
}
Loading