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-06)

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 6, 2024
1 parent 81c51e9 commit 6eab5df
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 228 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
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.Routing;
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;
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
30 changes: 26 additions & 4 deletions api/_types/_common.analysis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as Common from './_common'

export type Analyzer = CustomAnalyzer | FingerprintAnalyzer | KeywordAnalyzer | LanguageAnalyzer | NoriAnalyzer | PatternAnalyzer | SimpleAnalyzer | StandardAnalyzer | StopAnalyzer | WhitespaceAnalyzer | IcuAnalyzer | KuromojiAnalyzer | SnowballAnalyzer | DutchAnalyzer
export type Analyzer = CustomAnalyzer | FingerprintAnalyzer | KeywordAnalyzer | LanguageAnalyzer | NoriAnalyzer | PatternAnalyzer | SimpleAnalyzer | StandardAnalyzer | StopAnalyzer | WhitespaceAnalyzer | IcuAnalyzer | KuromojiAnalyzer | SnowballAnalyzer | DutchAnalyzer | SmartcnAnalyzer | CjkAnalyzer

export interface AsciiFoldingTokenFilter extends TokenFilterBase {
preserve_original?: Common.Stringifiedboolean;
Expand All @@ -37,6 +37,12 @@ export interface CharGroupTokenizer extends TokenizerBase {
type: 'char_group';
}

export interface CjkAnalyzer {
stopwords?: StopWords;
stopwords_path?: string;
type?: 'cjk';
}

export interface CommonGramsTokenFilter extends TokenFilterBase {
common_words?: string[];
common_words_path?: string;
Expand Down Expand Up @@ -160,7 +166,7 @@ export type IcuCollationAlternate = 'non-ignorable' | 'shifted'

export type IcuCollationCaseFirst = 'lower' | 'upper'

export type IcuCollationDecomposition = 'identical' | 'no'
export type IcuCollationDecomposition = 'canonical' | 'no'

export type IcuCollationStrength = 'identical' | 'primary' | 'quaternary' | 'secondary' | 'tertiary'

Expand Down Expand Up @@ -428,6 +434,10 @@ export interface PatternTokenizer extends TokenizerBase {
type: 'pattern';
}

export interface PersianStemTokenFilter extends TokenFilterBase {
type: 'persian_stem';
}

export type PhoneticEncoder = 'beider_morse' | 'caverphone1' | 'caverphone2' | 'cologne' | 'daitch_mokotoff' | 'double_metaphone' | 'haasephonetik' | 'koelnerphonetik' | 'metaphone' | 'nysiis' | 'refined_soundex' | 'soundex'

export type PhoneticLanguage = 'any' | 'common' | 'cyrillic' | 'english' | 'french' | 'german' | 'hebrew' | 'hungarian' | 'polish' | 'romanian' | 'russian' | 'spanish'
Expand Down Expand Up @@ -478,6 +488,18 @@ export interface SimpleAnalyzer {
version?: Common.VersionString;
}

export interface SmartcnAnalyzer {
type?: 'smartcn';
}

export interface SmartcnStopTokenFilter extends TokenFilterBase {
type: 'smartcn_stop';
}

export interface SmartcnTokenizer extends TokenizerBase {
type: 'smartcn_tokenizer';
}

export interface SnowballAnalyzer {
language: SnowballLanguage;
stopwords?: StopWords;
Expand Down Expand Up @@ -563,15 +585,15 @@ export interface TokenFilterBase {
version?: Common.VersionString;
}

export type TokenFilterDefinition = AsciiFoldingTokenFilter | CommonGramsTokenFilter | ConditionTokenFilter | DelimitedPayloadTokenFilter | EdgeNGramTokenFilter | ElisionTokenFilter | FingerprintTokenFilter | HunspellTokenFilter | HyphenationDecompounderTokenFilter | KeepTypesTokenFilter | KeepWordsTokenFilter | KeywordMarkerTokenFilter | KStemTokenFilter | LengthTokenFilter | LimitTokenCountTokenFilter | LowercaseTokenFilter | MultiplexerTokenFilter | NGramTokenFilter | NoriPartOfSpeechTokenFilter | PatternCaptureTokenFilter | PatternReplaceTokenFilter | PorterStemTokenFilter | PredicateTokenFilter | RemoveDuplicatesTokenFilter | ReverseTokenFilter | ShingleTokenFilter | SnowballTokenFilter | StemmerOverrideTokenFilter | StemmerTokenFilter | StopTokenFilter | SynonymGraphTokenFilter | SynonymTokenFilter | TrimTokenFilter | TruncateTokenFilter | UniqueTokenFilter | UppercaseTokenFilter | WordDelimiterGraphTokenFilter | WordDelimiterTokenFilter | KuromojiStemmerTokenFilter | KuromojiReadingFormTokenFilter | KuromojiPartOfSpeechTokenFilter | IcuTokenizer | IcuCollationTokenFilter | IcuFoldingTokenFilter | IcuNormalizationTokenFilter | IcuTransformTokenFilter | PhoneticTokenFilter | DictionaryDecompounderTokenFilter
export type TokenFilterDefinition = AsciiFoldingTokenFilter | CommonGramsTokenFilter | ConditionTokenFilter | DelimitedPayloadTokenFilter | EdgeNGramTokenFilter | ElisionTokenFilter | FingerprintTokenFilter | HunspellTokenFilter | HyphenationDecompounderTokenFilter | KeepTypesTokenFilter | KeepWordsTokenFilter | KeywordMarkerTokenFilter | KStemTokenFilter | LengthTokenFilter | LimitTokenCountTokenFilter | LowercaseTokenFilter | MultiplexerTokenFilter | NGramTokenFilter | NoriPartOfSpeechTokenFilter | PatternCaptureTokenFilter | PatternReplaceTokenFilter | PersianStemTokenFilter | PorterStemTokenFilter | PredicateTokenFilter | RemoveDuplicatesTokenFilter | ReverseTokenFilter | ShingleTokenFilter | SnowballTokenFilter | StemmerOverrideTokenFilter | StemmerTokenFilter | StopTokenFilter | SynonymGraphTokenFilter | SynonymTokenFilter | TrimTokenFilter | TruncateTokenFilter | UniqueTokenFilter | UppercaseTokenFilter | WordDelimiterGraphTokenFilter | WordDelimiterTokenFilter | KuromojiStemmerTokenFilter | KuromojiReadingFormTokenFilter | KuromojiPartOfSpeechTokenFilter | IcuTokenizer | IcuCollationTokenFilter | IcuFoldingTokenFilter | IcuNormalizationTokenFilter | IcuTransformTokenFilter | PhoneticTokenFilter | DictionaryDecompounderTokenFilter | SmartcnStopTokenFilter

export type Tokenizer = string | TokenizerDefinition

export interface TokenizerBase {
version?: Common.VersionString;
}

export type TokenizerDefinition = CharGroupTokenizer | EdgeNGramTokenizer | KeywordTokenizer | LetterTokenizer | LowercaseTokenizer | NGramTokenizer | NoriTokenizer | PathHierarchyTokenizer | StandardTokenizer | UaxEmailUrlTokenizer | WhitespaceTokenizer | KuromojiTokenizer | PatternTokenizer | IcuTokenizer
export type TokenizerDefinition = CharGroupTokenizer | EdgeNGramTokenizer | KeywordTokenizer | LetterTokenizer | LowercaseTokenizer | NGramTokenizer | NoriTokenizer | PathHierarchyTokenizer | StandardTokenizer | UaxEmailUrlTokenizer | WhitespaceTokenizer | KuromojiTokenizer | PatternTokenizer | IcuTokenizer | SmartcnTokenizer

export interface TrimTokenFilter extends TokenFilterBase {
type: 'trim';
Expand Down
8 changes: 6 additions & 2 deletions api/_types/_common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export interface BaseNode {
transport_address?: TransportAddress;
}

export type BatchSize = number

export type BulkByScrollFailure = BulkItemResponseFailure | ScrollableHitSourceSearchFailure

export interface BulkByScrollResponseBase extends BulkByScrollTaskStatus {
Expand Down Expand Up @@ -431,8 +433,6 @@ export interface NodeStatistics {
total: number;
}

export type Normalization = 'h1' | 'h2' | 'h3' | 'no' | 'z'

export interface OpenSearchVersionInfo {
build_date: DateTime;
build_flavor?: string;
Expand Down Expand Up @@ -604,6 +604,8 @@ export interface RequestStats {
total?: number;
}

export type ResourceType = 'index_or_alias'

export type Result = 'created' | 'deleted' | 'noop' | 'not_found' | 'updated'

export interface Retries {
Expand Down Expand Up @@ -817,6 +819,8 @@ export interface TaskFailure {

export type TaskId = string | number

export type TermFrequencyNormalization = 'h1' | 'h2' | 'h3' | 'no' | 'z'

export type TimeOfDay = string

export type TimeUnit = 'd' | 'h' | 'm' | 'micros' | 'ms' | 'nanos' | 's'
Expand Down
43 changes: 8 additions & 35 deletions api/_types/_common.mapping.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface CompletionProperty extends DocValuesPropertyBase {

export interface ConstantKeywordProperty extends PropertyBase {
type: 'constant_keyword';
value?: Record<string, any>;
value?: any;
}

export interface CorePropertyBase extends PropertyBase {
Expand Down Expand Up @@ -135,32 +135,6 @@ export interface DoubleRangeProperty extends RangePropertyBase {

export type DynamicMapping = 'false' | 'strict' | 'strict_allow_templates' | 'true'

export interface DynamicProperty extends DocValuesPropertyBase {
analyzer?: string;
boost?: number;
coerce?: boolean;
eager_global_ordinals?: boolean;
enabled?: boolean;
format?: string;
ignore_malformed?: boolean;
index?: boolean;
index_options?: IndexOptions;
index_phrases?: boolean;
index_prefixes?: TextIndexPrefixes;
locale?: string;
norms?: boolean;
null_value?: Common.FieldValue;
on_script_error?: OnScriptError;
position_increment_gap?: number;
precision_step?: number;
script?: Common.Script;
search_analyzer?: string;
search_quote_analyzer?: string;
term_vector?: TermVectorOption;
time_series_metric?: TimeSeriesMetricType;
type: '{dynamic_property}';
}

export interface DynamicTemplate {
mapping?: Property;
match?: string;
Expand Down Expand Up @@ -207,7 +181,7 @@ export interface FloatRangeProperty extends RangePropertyBase {
type: 'float_range';
}

export type GeoOrientation = 'left' | 'right'
export type GeoOrientation = 'LEFT' | 'clockwise' | 'cw' | 'left' | 'RIGHT' | 'ccw' | 'counterclockwise' | 'right'

export interface GeoPointProperty extends DocValuesPropertyBase {
ignore_malformed?: boolean;
Expand Down Expand Up @@ -290,21 +264,20 @@ export interface KeywordProperty extends DocValuesPropertyBase {
export interface KnnVectorMethod {
engine?: string;
name: string;
parameters?: Record<string, Record<string, any>>;
parameters?: {
};
space_type?: string;
}

export interface KnnVectorProperty extends KnnVectorPropertyBase {
type: 'knn_vector';
}

export interface KnnVectorPropertyBase {
export interface KnnVectorProperty extends DocValuesPropertyBase {
compression_level?: string;
data_type?: string;
dimension: number;
method?: KnnVectorMethod;
mode?: string;
model_id?: string;
space_type?: string;
type: 'knn_vector';
}

export interface LongNumberProperty extends NumberPropertyBase {
Expand Down Expand Up @@ -358,7 +331,7 @@ export interface PercolatorProperty extends PropertyBase {
type: 'percolator';
}

export type Property = BinaryProperty | BooleanProperty | DynamicProperty | JoinProperty | KeywordProperty | MatchOnlyTextProperty | PercolatorProperty | RankFeatureProperty | RankFeaturesProperty | SearchAsYouTypeProperty | TextProperty | VersionProperty | WildcardProperty | DateNanosProperty | DateProperty | AggregateMetricDoubleProperty | DenseVectorProperty | SparseVectorProperty | FlattenedProperty | NestedProperty | ObjectProperty | CompletionProperty | ConstantKeywordProperty | FieldAliasProperty | HistogramProperty | IpProperty | Murmur3HashProperty | TokenCountProperty | GeoPointProperty | GeoShapeProperty | XyPointProperty | XyShapeProperty | ByteNumberProperty | DoubleNumberProperty | FloatNumberProperty | HalfFloatNumberProperty | IntegerNumberProperty | LongNumberProperty | ScaledFloatNumberProperty | ShortNumberProperty | UnsignedLongNumberProperty | DateRangeProperty | DoubleRangeProperty | FloatRangeProperty | IntegerRangeProperty | IpRangeProperty | LongRangeProperty | KnnVectorProperty
export type Property = BinaryProperty | BooleanProperty | JoinProperty | KeywordProperty | MatchOnlyTextProperty | PercolatorProperty | RankFeatureProperty | RankFeaturesProperty | SearchAsYouTypeProperty | TextProperty | VersionProperty | WildcardProperty | DateNanosProperty | DateProperty | AggregateMetricDoubleProperty | DenseVectorProperty | SparseVectorProperty | FlattenedProperty | NestedProperty | ObjectProperty | CompletionProperty | ConstantKeywordProperty | FieldAliasProperty | HistogramProperty | IpProperty | Murmur3HashProperty | TokenCountProperty | GeoPointProperty | GeoShapeProperty | XyPointProperty | XyShapeProperty | ByteNumberProperty | DoubleNumberProperty | FloatNumberProperty | HalfFloatNumberProperty | IntegerNumberProperty | LongNumberProperty | ScaledFloatNumberProperty | ShortNumberProperty | UnsignedLongNumberProperty | DateRangeProperty | DoubleRangeProperty | FloatRangeProperty | IntegerRangeProperty | IpRangeProperty | LongRangeProperty | KnnVectorProperty

export interface PropertyBase {
dynamic?: DynamicMapping;
Expand Down
5 changes: 3 additions & 2 deletions api/_types/_core.search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export interface AggregationProfileDelegateDebugFilter {

export type BoundaryScanner = 'chars' | 'sentence' | 'word'

export type BuiltinHighlighterType = 'fvh' | 'plain' | 'unified'

export interface Collector {
children?: Collector[];
name: string;
Expand Down Expand Up @@ -136,7 +138,6 @@ export interface FetchProfileDebug {
}

export interface FieldCollapse {
collapse?: FieldCollapse;
field: Common.Field;
inner_hits?: InnerHits | InnerHits[];
max_concurrent_group_searches?: number;
Expand Down Expand Up @@ -179,7 +180,7 @@ export type HighlighterOrder = 'score'

export type HighlighterTagsSchema = 'styled'

export type HighlighterType = 'fvh' | 'plain' | 'unified'
export type HighlighterType = BuiltinHighlighterType | string

export interface HighlightField extends HighlightBase {
analyzer?: Common_Analysis.Analyzer;
Expand Down
Loading

0 comments on commit 6eab5df

Please sign in to comment.