Skip to content

Commit

Permalink
Updated opensearch-js to reflect the latest OpenSearch API spec (2024…
Browse files Browse the repository at this point in the history
…-10-21)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
nhtruong authored and github-actions[bot] committed Oct 21, 2024
1 parent 0519950 commit c5675d6
Show file tree
Hide file tree
Showing 43 changed files with 386 additions and 302 deletions.
4 changes: 4 additions & 0 deletions api/OpenSearchApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,10 @@ export default class OpenSearchAPI {
bulk (params: API.Bulk_Request, callback: callbackFn<API.Bulk_Response>): TransportRequestCallback;
bulk (params: API.Bulk_Request, options: TransportRequestOptions, callback: callbackFn<API.Bulk_Response>): TransportRequestCallback;

bulkStream (params: API.BulkStream_Request, options?: TransportRequestOptions): TransportRequestPromise<API.BulkStream_Response>;
bulkStream (params: API.BulkStream_Request, callback: callbackFn<API.BulkStream_Response>): TransportRequestCallback;
bulkStream (params: API.BulkStream_Request, options: TransportRequestOptions, callback: callbackFn<API.BulkStream_Response>): TransportRequestCallback;

count (params?: API.Count_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Count_Response>;
count (callback: callbackFn<API.Count_Response>): TransportRequestCallback;
count (params: API.Count_Request, callback: callbackFn<API.Count_Response>): TransportRequestCallback;
Expand Down
3 changes: 3 additions & 0 deletions api/OpenSearchApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class OpenSearchAPI {
// Setup Root API Functions
/** @namespace API-Core */
this.bulk = require('./_core/bulk').bind(this)
this.bulkStream = require('./_core/bulkStream').bind(this)
this.clearScroll = require('./_core/clearScroll').bind(this)
this.count = require('./_core/count').bind(this)
this.create = require('./_core/create').bind(this)
Expand Down Expand Up @@ -94,6 +95,8 @@ class OpenSearchAPI {
this.updateByQuery = require('./_core/updateByQuery').bind(this)
this.updateByQueryRethrottle = require('./_core/updateByQueryRethrottle').bind(this)

// Deprecated: Use bulkStream instead.
this.bulk_stream = require('./_core/bulkStream').bind(this)
// Deprecated: Use clearScroll instead.
this.clear_scroll = require('./_core/clearScroll').bind(this)
// Deprecated: Use createPit instead.
Expand Down
2 changes: 1 addition & 1 deletion api/_core/bulk.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface Bulk_Request extends Global.Params {
pipeline?: string;
refresh?: Common.Refresh;
require_alias?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
timeout?: Common.Duration;
type?: string;
wait_for_active_shards?: Common.WaitForActiveShards;
Expand Down
52 changes: 52 additions & 0 deletions api/_core/bulkStream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/

/*
* This file was generated from the OpenSearch API Spec. Do NOT edit it
* manually. If you want to make changes, either update the spec or
* modify the API generator.
*/

import { ApiResponse } from '../../lib/Transport'
import * as Common from '../_types/_common'
import * as Core_Bulk from '../_types/_core.bulk'
import * as Core_Search from '../_types/_core.search'
import * as Global from '../_types/_global'

export interface BulkStream_Request extends Global.Params {
_source?: Core_Search.SourceConfigParam;
_source_excludes?: Common.Fields;
_source_includes?: Common.Fields;
batch_interval?: Common.Duration;
batch_size?: Common.BatchSize;
body: BulkStream_RequestBody;
index?: Common.IndexName;
pipeline?: string;
refresh?: Common.Refresh;
require_alias?: boolean;
routing?: Common.RoutingInQueryString;
timeout?: Common.Duration;
type?: string;
wait_for_active_shards?: Common.WaitForActiveShards;
}

export type BulkStream_RequestBody = Core_Bulk.OperationContainer | Core_Bulk.UpdateAction | Record<string, any>[]

export interface BulkStream_Response extends ApiResponse {
body: BulkStream_ResponseBody;
}

export interface BulkStream_ResponseBody {
errors: boolean;
ingest_took?: number;
items: Record<string, Core_Bulk.ResponseItem>[];
took: number;
}

61 changes: 61 additions & 0 deletions api/_core/bulkStream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/

/*
* This file was generated from the OpenSearch API Spec. Do NOT edit it
* manually. If you want to make changes, either update the spec or
* modify the API generator.
*/

'use strict';

const { normalizeArguments, parsePathParam, handleMissingParam } = require('../utils');

/**
* Allows to perform multiple index/update/delete operations using request response streaming.
* <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/document-apis/bulk-streaming/ - bulk_stream}
*
* @memberOf API-Core
*
* @param {object} params
* @param {string} [params._source] - `true` or `false` to return the `_source` field or not, or a list of fields to return.
* @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude from the response.
* @param {string} [params._source_includes] - A comma-separated list of source fields to include in the response.
* @param {string} [params.batch_interval] - Specifies for how long bulk operations should be accumulated into a batch before sending the batch to data nodes.
* @param {number} [params.batch_size] - Specifies how many bulk operations should be accumulated into a batch before sending the batch to data nodes.
* @param {string} [params.pipeline] - ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter.
* @param {string} [params.refresh] - If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`.
* @param {boolean} [params.require_alias=false] - If `true`, the request's actions must target an index alias.
* @param {string} [params.routing] - Custom value used to route operations to a specific shard.
* @param {string} [params.timeout] - Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
* @param {string} [params.type] - Default document type for items which don't provide one.
* @param {string} [params.wait_for_active_shards] - The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
* @param {string} [params.index] - Name of the data stream, index, or index alias to perform bulk actions on.
* @param {array} params.body - The operation definition and data (action-data pairs), separated by newlines
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
* @param {function} [callback] - Callback that handles errors and response
*
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
*/
function bulkStreamFunc(params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);
if (params.body == null) return handleMissingParam('body', this, callback);

let { body, index, ...querystring } = params;
index = parsePathParam(index);

const path = ['/', index, '/_bulk/stream'].filter(c => c).join('').replace('//', '/');
const method = index == null ? 'POST' : 'PUT';

return this.transport.request({ method, path, querystring, bulkBody: body }, options, callback);
}

module.exports = bulkStreamFunc;
2 changes: 1 addition & 1 deletion api/_core/count.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface Count_Request extends Global.Params {
min_score?: number;
preference?: string;
q?: string;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
terminate_after?: number;
}

Expand Down
2 changes: 1 addition & 1 deletion api/_core/create.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Create_Request extends Global.Params {
index: Common.IndexName;
pipeline?: string;
refresh?: Common.Refresh;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
timeout?: Common.Duration;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/createPit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface CreatePit_Request extends Global.Params {
index: string[];
keep_alive?: Common.Duration;
preference?: string;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
}

export interface CreatePit_Response extends ApiResponse {
Expand Down
2 changes: 1 addition & 1 deletion api/_core/delete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Delete_Request extends Global.Params {
if_seq_no?: Common.SequenceNumber;
index: Common.IndexName;
refresh?: Common.Refresh;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
timeout?: Common.Duration;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/deleteByQuery.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface DeleteByQuery_Request extends Global.Params {
refresh?: boolean;
request_cache?: boolean;
requests_per_second?: number;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
scroll?: Common.Duration;
scroll_size?: number;
search_timeout?: Common.Duration;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/exists.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface Exists_Request extends Global.Params {
preference?: string;
realtime?: boolean;
refresh?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
stored_fields?: Common.Fields;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/existsSource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ExistsSource_Request extends Global.Params {
preference?: string;
realtime?: boolean;
refresh?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
}
Expand Down
2 changes: 1 addition & 1 deletion api/_core/explain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface Explain_Request extends Global.Params {
lenient?: boolean;
preference?: string;
q?: string;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
stored_fields?: Common.Fields;
}

Expand Down
2 changes: 1 addition & 1 deletion api/_core/get.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface Get_Request extends Global.Params {
preference?: string;
realtime?: boolean;
refresh?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
stored_fields?: Common.Fields;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/getSource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface GetSource_Request extends Global.Params {
preference?: string;
realtime?: boolean;
refresh?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
}
Expand Down
2 changes: 1 addition & 1 deletion api/_core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface Index_Request extends Global.Params {
pipeline?: string;
refresh?: Common.Refresh;
require_alias?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
timeout?: Common.Duration;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/mget.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface Mget_Request extends Global.Params {
preference?: string;
realtime?: boolean;
refresh?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
stored_fields?: Common.Fields;
}

Expand Down
2 changes: 1 addition & 1 deletion api/_core/mtermvectors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface Mtermvectors_Request extends Global.Params {
positions?: boolean;
preference?: string;
realtime?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
term_statistics?: boolean;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface Search_Request extends Global.Params {
q?: string;
request_cache?: boolean;
rest_total_hits_as_int?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
scroll?: Common.Duration;
search_pipeline?: string;
search_type?: Common.SearchType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/searchShards.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface SearchShards_Request extends Global.Params {
index?: Common.Indices;
local?: boolean;
preference?: string;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
}

export interface SearchShards_Response extends ApiResponse {
Expand Down
2 changes: 1 addition & 1 deletion api/_core/searchTemplate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface SearchTemplate_Request extends Global.Params {
preference?: string;
profile?: boolean;
rest_total_hits_as_int?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
scroll?: Common.Duration;
search_type?: Common.SearchType;
typed_keys?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/termvectors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface Termvectors_Request extends Global.Params {
positions?: boolean;
preference?: string;
realtime?: boolean;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
term_statistics?: boolean;
version?: Common.VersionNumber;
version_type?: Common.VersionType;
Expand Down
2 changes: 1 addition & 1 deletion api/_core/update.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface Update_Request extends Global.Params {
refresh?: Common.Refresh;
require_alias?: boolean;
retry_on_conflict?: number;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
timeout?: Common.Duration;
wait_for_active_shards?: Common.WaitForActiveShards;
}
Expand Down
2 changes: 1 addition & 1 deletion api/_core/updateByQuery.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface UpdateByQuery_Request extends Global.Params {
refresh?: boolean;
request_cache?: boolean;
requests_per_second?: number;
routing?: Common.Routing;
routing?: Common.RoutingInQueryString;
scroll?: Common.Duration;
scroll_size?: number;
search_timeout?: Common.Duration;
Expand Down
4 changes: 3 additions & 1 deletion api/_types/_common.aggregations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,9 @@ export interface MutualInformationHeuristic {
include_negatives?: boolean;
}

export type NestedAggregate = SingleBucketAggregateBase & Record<string, any>
export interface NestedAggregate extends SingleBucketAggregateBase {
doc_count?: number;
}

export interface NestedAggregation extends BucketAggregationBase {
path?: Common.Field;
Expand Down
Loading

0 comments on commit c5675d6

Please sign in to comment.