Skip to content

Commit

Permalink
Updated opensearch-js to reflect the latest OpenSearch API spec (2025…
Browse files Browse the repository at this point in the history
…-02-11)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
nhtruong authored and github-actions[bot] committed Feb 11, 2025
1 parent fbe5b1d commit 9024ed2
Show file tree
Hide file tree
Showing 30 changed files with 298 additions and 130 deletions.
4 changes: 4 additions & 0 deletions api/OpenSearchApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,10 @@ export default class OpenSearchAPI {
};

ml: {
executeAlgorithm (params: API.Ml_ExecuteAlgorithm_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Ml_ExecuteAlgorithm_Response>;
executeAlgorithm (params: API.Ml_ExecuteAlgorithm_Request, callback: callbackFn<API.Ml_ExecuteAlgorithm_Response>): TransportRequestCallback;
executeAlgorithm (params: API.Ml_ExecuteAlgorithm_Request, options: TransportRequestOptions, callback: callbackFn<API.Ml_ExecuteAlgorithm_Response>): TransportRequestCallback;

predict (params: API.Ml_Predict_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Ml_Predict_Response>;
predict (params: API.Ml_Predict_Request, callback: callbackFn<API.Ml_Predict_Response>): TransportRequestCallback;
predict (params: API.Ml_Predict_Request, options: TransportRequestOptions, callback: callbackFn<API.Ml_Predict_Response>): TransportRequestCallback;
Expand Down
3 changes: 2 additions & 1 deletion api/_types/_common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export type GetStats = {
missing_time?: Duration;
missing_time_in_millis: DurationValueUnitMillis;
missing_total: number;
time?: Duration;
time_in_millis: DurationValueUnitMillis;
total: number;
}
Expand Down Expand Up @@ -825,7 +826,7 @@ export type TaskFailure = {
task_id: number;
}

export type TaskId = string | number
export type TaskId = string

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

Expand Down
103 changes: 64 additions & 39 deletions api/_types/_common.query_dsl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ export type ConstantScoreQuery = QueryBase & {
filter: QueryContainer;
}

export type DateDecayFunction = DecayFunctionBase & Record<string, any>

export type DateDistanceFeatureQuery = DistanceFeatureQueryBaseDateMathDuration & Record<string, any>
export type DateDecayPlacement = {
decay?: number;
offset?: Common.Duration;
origin?: Common.DateTime;
scale?: Common.Duration;
}

export type DateRangeQuery = RangeQueryBase & {
export type DateRangeQueryParameters = {
format?: Common.DateFormat;
from?: Common.DateMath | undefined;
gt?: Common.DateMath;
Expand All @@ -76,30 +79,20 @@ export type DateRangeQuery = RangeQueryBase & {
to?: Common.DateMath | undefined;
}

export type DecayFunction = DateDecayFunction | NumericDecayFunction | GeoDecayFunction
export type DecayFunction = DecayFunctionBase & Record<string, DecayPlacement>

export type DecayFunctionBase = {
multi_value_mode?: MultiValueMode;
}

export type DecayPlacement = DateDecayPlacement | GeoDecayPlacement | NumericDecayPlacement

export type DisMaxQuery = QueryBase & {
queries: QueryContainer[];
tie_breaker?: number;
}

export type DistanceFeatureQuery = GeoDistanceFeatureQuery | DateDistanceFeatureQuery

export type DistanceFeatureQueryBaseDateMathDuration = QueryBase & {
field: Common.Field;
origin: Common.DateMath;
pivot: Common.Duration;
}

export type DistanceFeatureQueryBaseGeoLocationDistance = QueryBase & {
field: Common.Field;
origin: Common.GeoLocation;
pivot: Common.Distance;
}
export type DistanceFeatureQuery = QueryBase & Record<string, any>

export type ExistsQuery = QueryBase & {
field: Common.Field;
Expand All @@ -111,6 +104,13 @@ export type FieldAndFormat = Common.Field | {
include_unmapped?: boolean;
}

export type FieldLookup = {
id: Common.Id;
index?: Common.IndexName;
path?: Common.Field;
routing?: Common.Routing;
}

export type FieldValueFactorModifier = 'ln' | 'ln1p' | 'ln2p' | 'log' | 'log1p' | 'log2p' | 'none' | 'reciprocal' | 'sqrt' | 'square'

export type FieldValueFactorScoreFunction = {
Expand Down Expand Up @@ -160,9 +160,12 @@ export type GeoBoundingBoxQuery = QueryBase & {
[key: string]: any | Common.GeoBounds;
}

export type GeoDecayFunction = DecayFunctionBase & Record<string, any>

export type GeoDistanceFeatureQuery = DistanceFeatureQueryBaseGeoLocationDistance & Record<string, any>
export type GeoDecayPlacement = {
decay?: number;
offset?: Common.Distance;
origin?: Common.GeoLocation;
scale?: Common.Distance;
}

export type GeoDistanceQuery = QueryBase & {
distance: Common.Distance;
Expand All @@ -174,24 +177,30 @@ export type GeoDistanceQuery = QueryBase & {

export type GeoExecution = 'indexed' | 'memory'

export type GeoPolygonPoints = {
points: Common.GeoLocation[];
}

export type GeoPolygonQuery = QueryBase & {
ignore_unmapped?: IgnoreUnmapped;
validation_method?: GeoValidationMethod;
[key: string]: any | GeoPolygonPoints;
}

export type GeoShape = {
coordinates?: any[];
type?: string;
}

export type GeoShapeField = {
relation?: Common.GeoShapeRelation;
shape: GeoShape;
}

export type GeoShapeQuery = QueryBase & {
ignore_unmapped?: IgnoreUnmapped;
[key: string]: any | GeoShapeField;
[key: string]: any | GeoShapeQueryField;
}

export type GeoShapeQueryField = {
indexed_shape?: FieldLookup;
relation?: Common.GeoShapeRelation;
shape: GeoShape;
}

export type GeoValidationMethod = 'coerce' | 'ignore_malformed' | 'strict'
Expand Down Expand Up @@ -297,15 +306,18 @@ export type IntervalsWildcard = {
}

export type KnnQuery = QueryBase & {
filter?: QueryContainer | QueryContainer[];
expand_nested_docs?: boolean;
filter?: QueryContainer;
k?: number;
max_distance?: number;
method_parameters?: Record<string, number>;
method_parameters?: Record<string, any>;
min_score?: number;
rescore?: Record<string, number>;
rescore?: KnnQueryRescore;
vector: QueryVector;
}

export type KnnQueryRescore = boolean | RescoreContext

export type Like = string | LikeDocument

export type LikeDocument = {
Expand Down Expand Up @@ -429,16 +441,21 @@ export type NeuralQuery = QueryBase & {
query_text?: string;
}

export type NumberRangeQuery = RangeQueryBase & {
from?: undefined | number | string;
export type NumberRangeQueryParameters = {
from?: number | string | undefined;
gt?: number;
gte?: number;
lt?: number;
lte?: number;
to?: undefined | number | string;
to?: number | string | undefined;
}

export type NumericDecayFunction = DecayFunctionBase & Record<string, any>
export type NumericDecayPlacement = {
decay?: number;
offset?: number;
origin?: number;
scale?: number;
}

export type Operator = 'and' | 'AND' | 'or' | 'OR'

Expand Down Expand Up @@ -573,7 +590,7 @@ export type RandomScoreFunction = {
seed?: number | string;
}

export type RangeQuery = DateRangeQuery | NumberRangeQuery
export type RangeQuery = RangeQueryBase & Record<string, any>

export type RangeQueryBase = QueryBase & {
relation?: RangeRelation;
Expand Down Expand Up @@ -614,6 +631,10 @@ export type RegexpQuery = string | (QueryBase & {
value: string;
})

export type RescoreContext = {
oversample_factor?: number;
}

export type ScriptQuery = QueryBase & {
script: Common.Script;
}
Expand Down Expand Up @@ -757,12 +778,16 @@ export type XyShape = {
type?: string;
}

export type XyShapeField = {
export type XyShapeQuery = QueryBase & {
ignore_unmapped?: boolean;
[key: string]: any | XyShapeQueryField;
}

export type XyShapeQueryField = {
indexed_shape?: FieldLookup;
relation?: Common.GeoShapeRelation;
shape: XyShape;
}

export type XyShapeQuery = QueryBase & Record<string, XyShapeField>

export type ZeroTermsQuery = 'all' | 'none'
export type ZeroTermsQuery = 'all' | 'ALL' | 'none' | 'NONE'

34 changes: 34 additions & 0 deletions api/_types/ml._common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type AdditionalInfo = Record<string, any>

export type Aggregation = {
field?: string;
max?: Aggregation;
sum?: Aggregation;
[key: string]: any;
}
Expand All @@ -41,6 +42,7 @@ export type Algorithm = {

export type AlgorithmOperations = {
deploy?: ModelStats;
execute?: ModelStats;
predict?: ModelStats;
register?: ModelStats;
train?: ModelStats;
Expand All @@ -57,6 +59,13 @@ export type BoolQuery = {
should?: Filter[];
}

export type Buckets = {
end_time?: number;
entities?: Entity[];
overall_aggregate_value?: number;
start_time?: number;
}

export type ByteBuffer = {
array?: string;
order?: 'BIG_ENDIAN' | 'LITTLE_ENDIAN';
Expand Down Expand Up @@ -84,6 +93,26 @@ export type Credential = {
[key: string]: any;
}

export type Entity = {
base_value?: number;
contribution_value?: number;
key?: string[];
new_value?: number;
}

export type ExecuteAlgorithmResponse = ExecuteLocalSampleCalculatorResponse | {
results?: ExecuteAnomalyLocalizationResponse[];
}

export type ExecuteAnomalyLocalizationResponse = {
name?: string;
result?: Result;
}

export type ExecuteLocalSampleCalculatorResponse = {
result?: number;
}

export type Exists = {
field?: Common.Field;
}
Expand Down Expand Up @@ -258,6 +287,7 @@ export type ModelGroupRegistration = {

export type ModelProfile = {
deploy?: ModelStats;
execute?: ModelStats;
memory_size_estimation_cpu?: number;
memory_size_estimation_gpu?: number;
model_state?: 'DEPLOYED' | 'DEPLOYING' | 'DEPLOY_FAILED' | 'PARTIALLY_DEPLOYED' | 'REGISTERED' | 'REGISTERING' | 'UNDEPLOYED';
Expand Down Expand Up @@ -396,6 +426,10 @@ export type RateLimiter = {
unit: 'DAYS' | 'HOURS' | 'MICROSECONDS' | 'MILLISECONDS' | 'MINUTES' | 'NANOSECONDS' | 'SECONDS';
}

export type Result = {
buckets?: Buckets[];
}

export type Rows = {
values?: Values[];
}
Expand Down
6 changes: 3 additions & 3 deletions api/asynchronousSearch/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const { normalizeArguments } = require('../utils');
*
* @param {object} [params]
* @param {string} [params.index] - The name of the index to be searched. Can be an individual name, a comma-separated list of indexes, or a wildcard expression of index names.
* @param {string} [params.keep_alive] - The amount of time that the result is saved in the cluster. For example, `2d` means that the results are stored in the cluster for 48 hours. The saved search results are deleted after this period or if the search is canceled. Note that this includes the query execution time. If the query overruns this time, the process cancels this query automatically.
* @param {boolean} [params.keep_on_completion] - Whether you want to save the results in the cluster after the search is complete. You can examine the stored results at a later time.
* @param {string} [params.wait_for_completion_timeout] - The amount of time that you plan to wait for the results. You can poll the remaining results based on an ID. The maximum value is 300 seconds. Default is `1s`.
* @param {string} [params.keep_alive] - The amount of time that the result is saved in the cluster. For example, `2d` means that the results are stored in the cluster for 48 hours. The saved search results are deleted after this period or if the search is canceled. Note that this includes the query execution time. If the query exceeds this amount of time, the process cancels this query automatically.
* @param {boolean} [params.keep_on_completion] - Whether to save the results in the cluster after the search is complete. You can examine the stored results at a later time.
* @param {string} [params.wait_for_completion_timeout] - The amount of time to wait for the results. You can poll the remaining results based on an ID. The maximum value is 300 seconds. Default is `1s`.
* @param {object} [params.body] - The search definition using the Query DSL.
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
Expand Down
2 changes: 1 addition & 1 deletion api/asynchronousSearch/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
const { normalizeArguments } = require('../utils');

/**
* Monitors any asynchronous searches that are `running`, `completed`, `persisted`.
* Monitors any asynchronous searches that are `running`, `completed`, or `persisted`.
* <br/> See Also: {@link https://opensearch.org/docs/latest/search-plugins/async/index/#monitor-stats - asynchronous_search.stats}
*
* @memberOf API-Asynchronous-Search
Expand Down
8 changes: 4 additions & 4 deletions api/cluster/allocationExplain.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
const { normalizeArguments } = require('../utils');

/**
* Provides explanations for shard allocations in the cluster.
* Explains how shards are allocated in the current cluster and provides an explanation for why unassigned shards can't be allocated to a node.
* <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cluster-api/cluster-allocation/ - cluster.allocation_explain}
*
* @memberOf API-Cluster
*
* @param {object} [params]
* @param {boolean} [params.include_disk_info=false] - If `true`, returns information about disk usage and shard sizes.
* @param {boolean} [params.include_yes_decisions=false] - If `true`, returns YES decisions in explanation.
* @param {object} [params.body] - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard'
* @param {boolean} [params.include_disk_info=false] - When `true`, returns information about disk usage and shard sizes.
* @param {boolean} [params.include_yes_decisions=false] - When `true`, returns any `YES` decisions in the allocation explanation.
* @param {object} [params.body] - The index, shard, and primary flag for which to generate an explanation. Leave this empty to generate an explanation for the first unassigned shard.
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
* @param {function} [callback] - Callback that handles errors and response
Expand Down
6 changes: 3 additions & 3 deletions api/cluster/deleteComponentTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const { normalizeArguments, parsePathParam, handleMissingParam } = require('../u
*
* @param {object} params
* @param {string} [params.cluster_manager_timeout] - Operation timeout for connection to cluster-manager node.
* @param {string} [params.master_timeout] DEPRECATED - Period to wait for a connection to the cluster-manager node. If no response is received before the timeout expires, the request fails and returns an error.
* @param {string} [params.timeout] - Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
* @param {string} params.name - Name of the component template to delete. Wildcard (*) expressions are supported.
* @param {string} [params.master_timeout] DEPRECATED - A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
* @param {string} [params.timeout] - A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
* @param {string} params.name - The name of the component template to delete. Supports wildcard (*) expressions.
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
* @param {function} [callback] - Callback that handles errors and response
Expand Down
2 changes: 1 addition & 1 deletion api/cluster/deleteDecommissionAwareness.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
const { normalizeArguments } = require('../utils');

/**
* Delete any existing decommission.
* Recommissions a decommissioned zone.
* <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/cluster-api/cluster-decommission/#example-decommissioning-and-recommissioning-a-zone - cluster.delete_decommission_awareness}
*
* @memberOf API-Cluster
Expand Down
4 changes: 2 additions & 2 deletions api/cluster/deleteVotingConfigExclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
const { normalizeArguments } = require('../utils');

/**
* Clears cluster voting config exclusions.
* Clears any cluster voting configuration exclusions.
* <br/> See Also: {@link https://opensearch.org/docs/latest - cluster.delete_voting_config_exclusions}
*
* @memberOf API-Cluster
*
* @param {object} [params]
* @param {boolean} [params.wait_for_removal=true] - Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. Defaults to true, meaning that all excluded nodes must be removed from the cluster before this API takes any action. If set to `false` then the voting configuration exclusions list is cleared even if some excluded nodes are still in the cluster.
* @param {boolean} [params.wait_for_removal=true] - Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. When `true`, all excluded nodes are removed from the cluster before this API takes any action. When `false`, the voting configuration exclusions list is cleared even if some excluded nodes are still in the cluster.
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
* @param {function} [callback] - Callback that handles errors and response
Expand Down
Loading

0 comments on commit 9024ed2

Please sign in to comment.