@opensearch-project/opensearch 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/MAINTAINERS.md +5 -5
- package/USER_GUIDE.md +34 -4
- package/api/api/http.js +213 -0
- package/api/api/indices.js +1 -1
- package/api/index.js +11 -0
- package/api/new.d.ts +17 -0
- package/api/requestParams.d.ts +7 -0
- package/api/types.d.ts +11 -11
- package/guides/advanced_index_actions.md +3 -2
- package/guides/bulk.md +73 -113
- package/guides/index_lifecycle.md +4 -14
- package/guides/json.md +53 -0
- package/guides/msearch.md +56 -0
- package/guides/search.md +17 -31
- package/index.d.ts +89 -1
- package/index.js +1 -0
- package/lib/Connection.d.ts +2 -2
- package/lib/Transport.d.ts +2 -1
- package/lib/Transport.js +7 -2
- package/lib/aws/AwsSigv4Signer.js +23 -1
- package/lib/pool/index.d.ts +13 -2
- package/lib/tools.d.ts +11 -0
- package/lib/tools.js +21 -0
- package/package.json +8 -2
- package/samples/README.md +17 -0
- package/samples/bulk.js +91 -0
- package/samples/json.js +75 -0
- package/samples/msearch.js +131 -0
- package/samples/search.js +155 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,62 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
|
9
9
|
### Deprecated
|
|
10
10
|
### Removed
|
|
11
11
|
### Fixed
|
|
12
|
+
|
|
13
|
+
## [2.6.0]
|
|
14
|
+
### Added
|
|
15
|
+
- Inherit AwsSigV4 in .child ([#725](https://github.com/opensearch-project/opensearch-js/pull/725))
|
|
16
|
+
### Dependencies
|
|
17
|
+
- Bumps `prettier` from 3.1.1 to 3.2.5
|
|
18
|
+
- Bumps `@aws-sdk/types` from 3.485.0 to 3.523.0
|
|
19
|
+
- Bumps `@types/node` from 20.10.7 to 20.11.24
|
|
20
|
+
- Bumps `eslint-plugin-prettier` from 5.1.2 to 5.1.3
|
|
21
|
+
- Bumps `@babel/eslint-parser` from 7.23.3 to 7.23.10
|
|
22
|
+
- Bumps `semver` from 7.5.1 to 7.6.0
|
|
23
|
+
- Bumps `cross-zip` from 4.0.0 to 4.0.1
|
|
24
|
+
- Bumps `eslint` from 8.56.0 to 8.57.0
|
|
25
|
+
### Changed
|
|
26
|
+
- Updated integration tests to use strong password in OS 2.12 and up ([#707](https://github.com/opensearch-project/opensearch-js/pull/707))
|
|
27
|
+
- Simplified client creation in the guides ([#707](https://github.com/opensearch-project/opensearch-js/pull/707))
|
|
28
|
+
- Corrected `guides/bulk.md` ([#616](https://github.com/opensearch-project/opensearch-js/issues/616))
|
|
29
|
+
### Deprecated
|
|
30
|
+
### Removed
|
|
31
|
+
- Removed AutoHeal([#707](https://github.com/opensearch-project/opensearch-js/pull/707))
|
|
32
|
+
### Fixed
|
|
33
|
+
- Make optional fields optional in `MappingGenericProperty` ([708](https://github.com/opensearch-project/opensearch-js/pull/708))
|
|
34
|
+
### Security
|
|
35
|
+
|
|
36
|
+
## [2.5.0]
|
|
37
|
+
### Added
|
|
38
|
+
- Added deprecation warnings for Index Template APIs ([654](https://github.com/opensearch-project/opensearch-js/pull/645))
|
|
39
|
+
- Added `http` functions: `connect`, `delete`, `get`, `head`, `options`, `patch`, `post`, `put`, and `trace` ([#649](https://github.com/opensearch-project/opensearch-js/pull/649))
|
|
40
|
+
- Added `samples/search.js` and updated `guides/search.md` to provide example to search functionality ([#656](https://github.com/opensearch-project/opensearch-js/pull/656))
|
|
41
|
+
- Added `samples/msearch.js` and `guides/msearch.md` to provide example to multi-search functionality ([#657](https://github.com/opensearch-project/opensearch-js/pull/657))
|
|
42
|
+
- Updated `guides/index_lifecycle.md` to provide example of `ignore_unavailable: true` while deleting indices. ([665](https://github.com/opensearch-project/opensearch-js/pull/665))
|
|
43
|
+
- Add expiration buffer to prevent credentials to expire earlier than request may finish in case AWS SDK v3 is used. ([678](https://github.com/opensearch-project/opensearch-js/pull/678))
|
|
44
|
+
### Dependencies
|
|
45
|
+
- Bumps `@aws-sdk/types` from 3.418.0 to 3.451.0
|
|
46
|
+
- Bumps `@types/node` from 20.6.5 to 20.9.0
|
|
47
|
+
- Bumps `eslint` from 8.50.0 to 8.54.0
|
|
48
|
+
- Bumps `@babel/traverse` from 7.15.0 to 7.23.2
|
|
49
|
+
- Bumps `eslint-plugin-prettier` from 5.0.0 to 5.0.1
|
|
50
|
+
- Bumps `react-devtools-core` from 4.25.0 to 4.28.4
|
|
51
|
+
- Bumps `simple-git` from 3.20.0 to 3.21.0
|
|
52
|
+
- Bumps `prettier` from 3.0.3 to 3.1.0
|
|
53
|
+
- Bumps `@babel/eslint-parser` from 7.22.15 to 7.23.3
|
|
54
|
+
- Bumps `@types/node` from 20.9.0 to 20.10.7
|
|
55
|
+
- Bumps `eslint` from 8.54.0 to 8.56.0
|
|
56
|
+
- Bumps `@aws-sdk/types` from 3.451.0 to 3.485.0
|
|
57
|
+
- Bumps `prettier` from 3.1.0 to 3.1.1
|
|
58
|
+
- Bumps `eslint-plugin-prettier` from 5.0.1 to 5.1.2
|
|
59
|
+
- Bumps `eslint-config-prettier` from 9.0.0 to 9.1.0
|
|
60
|
+
- Bumps `ora` from 7.0.1 to 8.0.1
|
|
61
|
+
- Bumps `simple-git` from 3.21.0 to 3.22.0
|
|
62
|
+
### Changed
|
|
63
|
+
### Deprecated
|
|
64
|
+
### Removed
|
|
65
|
+
- Removed fixture lines that git-secrets wrongly flagged as passwords/secrets ([654](https://github.com/opensearch-project/opensearch-js/pull/645))
|
|
66
|
+
### Fixed
|
|
67
|
+
- Add new types to `package.json` exports configuration for ESM support ([#674](https://github.com/opensearch-project/opensearch-js/pull/674))
|
|
12
68
|
### Security
|
|
13
69
|
|
|
14
70
|
## [2.4.0]
|
|
@@ -35,6 +91,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
|
35
91
|
### Deprecated
|
|
36
92
|
### Removed
|
|
37
93
|
### Fixed
|
|
94
|
+
- Fix wrong documentation for file serach.md regarding `search_after` param ([#584](https://github.com/opensearch-project/opensearch-js/pull/584))
|
|
38
95
|
### Security
|
|
39
96
|
|
|
40
97
|
## [2.3.0]
|
package/MAINTAINERS.md
CHANGED
|
@@ -8,7 +8,6 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
|
|
|
8
8
|
|-----------------------|-----------------------------------------------|-------------|
|
|
9
9
|
| Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
|
|
10
10
|
| Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
|
|
11
|
-
| Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
|
|
12
11
|
| Daniel Doubrovkine | [dblock](https://github.com/dblock) | Amazon |
|
|
13
12
|
| Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon |
|
|
14
13
|
| Theo Truong | [nhtruong](https://github.com/nhtruong) | Amazon |
|
|
@@ -17,7 +16,8 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
|
|
|
17
16
|
|
|
18
17
|
## Emeritus
|
|
19
18
|
|
|
20
|
-
| Maintainer | GitHub ID
|
|
21
|
-
|
|
22
|
-
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb)
|
|
23
|
-
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni)
|
|
19
|
+
| Maintainer | GitHub ID | Affiliation |
|
|
20
|
+
|---------------|-----------------------------------------------|-------------|
|
|
21
|
+
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb) | Amazon |
|
|
22
|
+
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
|
|
23
|
+
| Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
|
package/USER_GUIDE.md
CHANGED
|
@@ -5,12 +5,17 @@
|
|
|
5
5
|
- [Authenticate with Amazon OpenSearch Service](#authenticate-with-amazon-opensearch-service)
|
|
6
6
|
- [Using AWS V2 SDK](#using-aws-v2-sdk)
|
|
7
7
|
- [Using AWS V3 SDK](#using-aws-v3-sdk)
|
|
8
|
-
- [Enable Handling of Long Numerals](#enable-handling-of-long-numerals)
|
|
8
|
+
- [Enable Handling of Long Numerals](#enable-handling-of-long-numerals)
|
|
9
9
|
- [Create an Index](#create-an-index)
|
|
10
10
|
- [Add a Document to the Index](#add-a-document-to-the-index)
|
|
11
11
|
- [Search for the Document](#search-for-the-document)
|
|
12
|
+
- [Multi-Search (msearch)](#multi-search-msearch)
|
|
12
13
|
- [Delete the document](#delete-the-document)
|
|
13
14
|
- [Delete the index](#delete-the-index)
|
|
15
|
+
- [Create a Point in Time](#create-a-point-in-time)
|
|
16
|
+
- [Get all PITs](#get-all-pits)
|
|
17
|
+
- [Delete a Point in Time](#delete-a-point-in-time)
|
|
18
|
+
- [Delete all PITs](#delete-all-pits)
|
|
14
19
|
- [Empty all Pool Connections](#empty-all-pool-connections)
|
|
15
20
|
|
|
16
21
|
## Initializing a Client
|
|
@@ -21,7 +26,7 @@
|
|
|
21
26
|
var host = 'localhost';
|
|
22
27
|
var protocol = 'https';
|
|
23
28
|
var port = 9200;
|
|
24
|
-
var auth = 'admin:
|
|
29
|
+
var auth = 'admin:strongPassword@999'; // For testing only. Don't store credentials in code.
|
|
25
30
|
var ca_certs_path = '/full/path/to/root-ca.pem';
|
|
26
31
|
|
|
27
32
|
// Optional client certificates if you don't want to use HTTP basic authentication.
|
|
@@ -94,8 +99,8 @@ const client = new Client({
|
|
|
94
99
|
// Must return a Promise that resolve to an AWS.Credentials object.
|
|
95
100
|
// This function is used to acquire the credentials when the client start and
|
|
96
101
|
// when the credentials are expired.
|
|
97
|
-
// The Client will
|
|
98
|
-
//
|
|
102
|
+
// The Client will treat the Credentials as expired if within
|
|
103
|
+
// `requestTimeout` ms of expiration (default is 30000 ms).
|
|
99
104
|
|
|
100
105
|
// Example with AWS SDK V3:
|
|
101
106
|
getCredentials: () => {
|
|
@@ -104,6 +109,7 @@ const client = new Client({
|
|
|
104
109
|
return credentialsProvider();
|
|
105
110
|
},
|
|
106
111
|
}),
|
|
112
|
+
requestTimeout: 60000, // Also used for refreshing credentials in advance
|
|
107
113
|
node: 'https://search-xxx.region.es.amazonaws.com', // OpenSearch domain URL
|
|
108
114
|
// node: "https://xxx.region.aoss.amazonaws.com" for OpenSearch Serverless
|
|
109
115
|
});
|
|
@@ -194,6 +200,30 @@ var response = await client.search({
|
|
|
194
200
|
console.log(response.body.hits);
|
|
195
201
|
```
|
|
196
202
|
|
|
203
|
+
## Multi-Search (msearch)
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
const queries = [
|
|
207
|
+
{},
|
|
208
|
+
{ query: { match: { author: 'Stephen King' } } },
|
|
209
|
+
{},
|
|
210
|
+
{ query: { match: { title: 'The Outsider' } } },
|
|
211
|
+
];
|
|
212
|
+
|
|
213
|
+
const multiSearchResponse = await client.msearch({
|
|
214
|
+
index: index_name,
|
|
215
|
+
body: queries,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
multiSearchResponse.body.responses.map((res) =>
|
|
219
|
+
res.hits.hits.map((movie) => {
|
|
220
|
+
console.log(movie._source);
|
|
221
|
+
})
|
|
222
|
+
);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Explore `msearch` further with a detailed guide in [msearch.md](guides/msearch.md) and find sample code in [msearch.js](samples/msearch.js).
|
|
226
|
+
|
|
197
227
|
## Delete the document
|
|
198
228
|
|
|
199
229
|
```javascript
|
package/api/api/http.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/** @namespace API-HTTP */
|
|
14
|
+
|
|
15
|
+
const { normalizeArguments, kConfigurationError } = require('../utils');
|
|
16
|
+
|
|
17
|
+
function HttpApi(transport, ConfigurationError) {
|
|
18
|
+
this.transport = transport;
|
|
19
|
+
this[kConfigurationError] = ConfigurationError;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
HttpApi.prototype.request = function (method, params, options, callback) {
|
|
23
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
24
|
+
if (Array.isArray(params.body)) {
|
|
25
|
+
const { path, querystring, headers, body } = params;
|
|
26
|
+
params = { path, querystring, headers, bulkBody: body };
|
|
27
|
+
}
|
|
28
|
+
options = options || {};
|
|
29
|
+
options.headers = params.headers || options.headers;
|
|
30
|
+
return this.transport.request({ ...params, method }, options, callback);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Make a customized CONNECT request.
|
|
35
|
+
*
|
|
36
|
+
* @memberOf API-HTTP
|
|
37
|
+
*
|
|
38
|
+
* @param {Object} params
|
|
39
|
+
* @param {Object} params.path - The URL of the request
|
|
40
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
41
|
+
* @param {Object} [params.headers] - The request headers
|
|
42
|
+
* @param {Object} [params.body] - The request body
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
45
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
46
|
+
*
|
|
47
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
48
|
+
*/
|
|
49
|
+
HttpApi.prototype.connect = function (params, options, callback) {
|
|
50
|
+
return this.request('CONNECT', params, options, callback);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Make a customized DELETE request.
|
|
55
|
+
*
|
|
56
|
+
* @memberOf API-HTTP
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} params
|
|
59
|
+
* @param {Object} params.path - The URL of the request
|
|
60
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
61
|
+
* @param {Object} [params.headers] - The request headers
|
|
62
|
+
* @param {Object} [params.body] - The request body
|
|
63
|
+
*
|
|
64
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
65
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
66
|
+
*
|
|
67
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
68
|
+
*/
|
|
69
|
+
HttpApi.prototype.delete = function (params, options, callback) {
|
|
70
|
+
return this.request('DELETE', params, options, callback);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Make a customized GET request.
|
|
75
|
+
*
|
|
76
|
+
* @memberOf API-HTTP
|
|
77
|
+
*
|
|
78
|
+
* @param {Object} params
|
|
79
|
+
* @param {Object} params.path - The URL of the request
|
|
80
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
81
|
+
* @param {Object} [params.headers] - The request headers
|
|
82
|
+
* @param {Object} [params.body] - The request body
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
85
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
86
|
+
*
|
|
87
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
88
|
+
*/
|
|
89
|
+
HttpApi.prototype.get = function (params, options, callback) {
|
|
90
|
+
return this.request('GET', params, options, callback);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Make a customized HEAD request.
|
|
95
|
+
*
|
|
96
|
+
* @memberOf API-HTTP
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} params
|
|
99
|
+
* @param {Object} params.path - The URL of the request
|
|
100
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
101
|
+
* @param {Object} [params.headers] - The request headers
|
|
102
|
+
* @param {Object} [params.body] - The request body
|
|
103
|
+
*
|
|
104
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
105
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
106
|
+
*
|
|
107
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
108
|
+
*/
|
|
109
|
+
HttpApi.prototype.head = function (params, options, callback) {
|
|
110
|
+
return this.request('HEAD', params, options, callback);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Make a customized OPTIONS request.
|
|
115
|
+
*
|
|
116
|
+
* @memberOf API-HTTP
|
|
117
|
+
*
|
|
118
|
+
* @param {Object} params
|
|
119
|
+
* @param {Object} params.path - The URL of the request
|
|
120
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
121
|
+
* @param {Object} [params.headers] - The request headers
|
|
122
|
+
* @param {Object} [params.body] - The request body
|
|
123
|
+
*
|
|
124
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
125
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
126
|
+
*
|
|
127
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
128
|
+
*/
|
|
129
|
+
HttpApi.prototype.options = function (params, options, callback) {
|
|
130
|
+
return this.request('OPTIONS', params, options, callback);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Make a customized PATCH request.
|
|
135
|
+
*
|
|
136
|
+
* @memberOf API-HTTP
|
|
137
|
+
*
|
|
138
|
+
* @param {Object} params
|
|
139
|
+
* @param {Object} params.path - The URL of the request
|
|
140
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
141
|
+
* @param {Object} [params.headers] - The request headers
|
|
142
|
+
* @param {Object} [params.body] - The request body
|
|
143
|
+
*
|
|
144
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
145
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
146
|
+
*
|
|
147
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
148
|
+
*/
|
|
149
|
+
HttpApi.prototype.patch = function (params, options, callback) {
|
|
150
|
+
return this.request('PATCH', params, options, callback);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Make a customized POST request.
|
|
155
|
+
*
|
|
156
|
+
* @memberOf API-HTTP
|
|
157
|
+
*
|
|
158
|
+
* @param {Object} params
|
|
159
|
+
* @param {Object} params.path - The URL of the request
|
|
160
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
161
|
+
* @param {Object} [params.headers] - The request headers
|
|
162
|
+
* @param {Object} [params.body] - The request body
|
|
163
|
+
*
|
|
164
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
165
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
166
|
+
*
|
|
167
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
168
|
+
*/
|
|
169
|
+
HttpApi.prototype.post = function (params, options, callback) {
|
|
170
|
+
return this.request('POST', params, options, callback);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Make a customized PUT request.
|
|
175
|
+
*
|
|
176
|
+
* @memberOf API-HTTP
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} params
|
|
179
|
+
* @param {Object} params.path - The URL of the request
|
|
180
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
181
|
+
* @param {Object} [params.headers] - The request headers
|
|
182
|
+
* @param {Object} [params.body] - The request body
|
|
183
|
+
*
|
|
184
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
185
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
186
|
+
*
|
|
187
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
188
|
+
*/
|
|
189
|
+
HttpApi.prototype.put = function (params, options, callback) {
|
|
190
|
+
return this.request('PUT', params, options, callback);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Make a customized TRACE request.
|
|
195
|
+
*
|
|
196
|
+
* @memberOf API-HTTP
|
|
197
|
+
*
|
|
198
|
+
* @param {Object} params
|
|
199
|
+
* @param {Object} params.path - The URL of the request
|
|
200
|
+
* @param {Object} [params.querystring] - The querystring parameters
|
|
201
|
+
* @param {Object} [params.headers] - The request headers
|
|
202
|
+
* @param {Object} [params.body] - The request body
|
|
203
|
+
*
|
|
204
|
+
* @param {Object} [options] - Options for {@link Transport#request}
|
|
205
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
206
|
+
*
|
|
207
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
208
|
+
*/
|
|
209
|
+
HttpApi.prototype.trace = function (params, options, callback) {
|
|
210
|
+
return this.request('TRACE', params, options, callback);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
module.exports = HttpApi;
|
package/api/api/indices.js
CHANGED
|
@@ -1336,7 +1336,7 @@ IndicesApi.prototype.getTemplate = function indicesGetTemplateApi(params, option
|
|
|
1336
1336
|
};
|
|
1337
1337
|
|
|
1338
1338
|
/**
|
|
1339
|
-
* Returns a progress status of current upgrade.
|
|
1339
|
+
* Returns a progress status of current upgrade.
|
|
1340
1340
|
*
|
|
1341
1341
|
* @memberOf API-Index
|
|
1342
1342
|
*
|
package/api/index.js
CHANGED
|
@@ -54,6 +54,7 @@ const getScriptApi = require('./api/get_script');
|
|
|
54
54
|
const getScriptContextApi = require('./api/get_script_context');
|
|
55
55
|
const getScriptLanguagesApi = require('./api/get_script_languages');
|
|
56
56
|
const getSourceApi = require('./api/get_source');
|
|
57
|
+
const HttpApi = require('./api/http');
|
|
57
58
|
const indexApi = require('./api/index');
|
|
58
59
|
const IndicesApi = require('./api/indices');
|
|
59
60
|
const infoApi = require('./api/info');
|
|
@@ -89,6 +90,7 @@ const kCat = Symbol('Cat');
|
|
|
89
90
|
const kCluster = Symbol('Cluster');
|
|
90
91
|
const kDanglingIndices = Symbol('DanglingIndices');
|
|
91
92
|
const kFeatures = Symbol('Features');
|
|
93
|
+
const kHttp = Symbol('Http');
|
|
92
94
|
const kIndices = Symbol('Indices');
|
|
93
95
|
const kIngest = Symbol('Ingest');
|
|
94
96
|
const kNodes = Symbol('Nodes');
|
|
@@ -103,6 +105,7 @@ function OpenSearchAPI(opts) {
|
|
|
103
105
|
this[kCluster] = null;
|
|
104
106
|
this[kDanglingIndices] = null;
|
|
105
107
|
this[kFeatures] = null;
|
|
108
|
+
this[kHttp] = null;
|
|
106
109
|
this[kIndices] = null;
|
|
107
110
|
this[kIngest] = null;
|
|
108
111
|
this[kNodes] = null;
|
|
@@ -264,6 +267,14 @@ Object.defineProperties(OpenSearchAPI.prototype, {
|
|
|
264
267
|
return this.getSource;
|
|
265
268
|
},
|
|
266
269
|
},
|
|
270
|
+
http: {
|
|
271
|
+
get() {
|
|
272
|
+
if (this[kHttp] === null) {
|
|
273
|
+
this[kHttp] = new HttpApi(this.transport, this[kConfigurationError]);
|
|
274
|
+
}
|
|
275
|
+
return this[kHttp];
|
|
276
|
+
},
|
|
277
|
+
},
|
|
267
278
|
indices: {
|
|
268
279
|
get() {
|
|
269
280
|
if (this[kIndices] === null) {
|
package/api/new.d.ts
CHANGED
|
@@ -951,14 +951,17 @@ declare class Client {
|
|
|
951
951
|
options: TransportRequestOptions,
|
|
952
952
|
callback: callbackFn<T.IndicesDeleteIndexTemplateResponse, TContext>
|
|
953
953
|
): TransportRequestCallback;
|
|
954
|
+
/** @deprecated use deleteIndexTemplate instead */
|
|
954
955
|
deleteTemplate<TContext = unknown>(
|
|
955
956
|
params: T.IndicesDeleteTemplateRequest,
|
|
956
957
|
options?: TransportRequestOptions
|
|
957
958
|
): TransportRequestPromise<ApiResponse<T.IndicesDeleteTemplateResponse, TContext>>;
|
|
959
|
+
/** @deprecated use deleteIndexTemplate instead */
|
|
958
960
|
deleteTemplate<TContext = unknown>(
|
|
959
961
|
params: T.IndicesDeleteTemplateRequest,
|
|
960
962
|
callback: callbackFn<T.IndicesDeleteTemplateResponse, TContext>
|
|
961
963
|
): TransportRequestCallback;
|
|
964
|
+
/** @deprecated use deleteIndexTemplate instead */
|
|
962
965
|
deleteTemplate<TContext = unknown>(
|
|
963
966
|
params: T.IndicesDeleteTemplateRequest,
|
|
964
967
|
options: TransportRequestOptions,
|
|
@@ -1017,14 +1020,17 @@ declare class Client {
|
|
|
1017
1020
|
options: TransportRequestOptions,
|
|
1018
1021
|
callback: callbackFn<T.IndicesExistsIndexTemplateResponse, TContext>
|
|
1019
1022
|
): TransportRequestCallback;
|
|
1023
|
+
/** @deprecated use existsIndexTemplate instead */
|
|
1020
1024
|
existsTemplate<TContext = unknown>(
|
|
1021
1025
|
params: T.IndicesExistsTemplateRequest,
|
|
1022
1026
|
options?: TransportRequestOptions
|
|
1023
1027
|
): TransportRequestPromise<ApiResponse<T.IndicesExistsTemplateResponse, TContext>>;
|
|
1028
|
+
/** @deprecated use existsIndexTemplate instead */
|
|
1024
1029
|
existsTemplate<TContext = unknown>(
|
|
1025
1030
|
params: T.IndicesExistsTemplateRequest,
|
|
1026
1031
|
callback: callbackFn<T.IndicesExistsTemplateResponse, TContext>
|
|
1027
1032
|
): TransportRequestCallback;
|
|
1033
|
+
/** @deprecated use existsIndexTemplate instead */
|
|
1028
1034
|
existsTemplate<TContext = unknown>(
|
|
1029
1035
|
params: T.IndicesExistsTemplateRequest,
|
|
1030
1036
|
options: TransportRequestOptions,
|
|
@@ -1168,17 +1174,21 @@ declare class Client {
|
|
|
1168
1174
|
options: TransportRequestOptions,
|
|
1169
1175
|
callback: callbackFn<T.IndicesGetSettingsResponse, TContext>
|
|
1170
1176
|
): TransportRequestCallback;
|
|
1177
|
+
/** @deprecated use getIndexTemplate instead */
|
|
1171
1178
|
getTemplate<TContext = unknown>(
|
|
1172
1179
|
params?: T.IndicesGetTemplateRequest,
|
|
1173
1180
|
options?: TransportRequestOptions
|
|
1174
1181
|
): TransportRequestPromise<ApiResponse<T.IndicesGetTemplateResponse, TContext>>;
|
|
1182
|
+
/** @deprecated use getIndexTemplate instead */
|
|
1175
1183
|
getTemplate<TContext = unknown>(
|
|
1176
1184
|
callback: callbackFn<T.IndicesGetTemplateResponse, TContext>
|
|
1177
1185
|
): TransportRequestCallback;
|
|
1186
|
+
/** @deprecated use getIndexTemplate instead */
|
|
1178
1187
|
getTemplate<TContext = unknown>(
|
|
1179
1188
|
params: T.IndicesGetTemplateRequest,
|
|
1180
1189
|
callback: callbackFn<T.IndicesGetTemplateResponse, TContext>
|
|
1181
1190
|
): TransportRequestCallback;
|
|
1191
|
+
/** @deprecated use getIndexTemplate instead */
|
|
1182
1192
|
getTemplate<TContext = unknown>(
|
|
1183
1193
|
params: T.IndicesGetTemplateRequest,
|
|
1184
1194
|
options: TransportRequestOptions,
|
|
@@ -1269,14 +1279,17 @@ declare class Client {
|
|
|
1269
1279
|
options: TransportRequestOptions,
|
|
1270
1280
|
callback: callbackFn<T.IndicesPutSettingsResponse, TContext>
|
|
1271
1281
|
): TransportRequestCallback;
|
|
1282
|
+
/** @deprecated use putIndexTemplate instead */
|
|
1272
1283
|
putTemplate<TContext = unknown>(
|
|
1273
1284
|
params: T.IndicesPutTemplateRequest,
|
|
1274
1285
|
options?: TransportRequestOptions
|
|
1275
1286
|
): TransportRequestPromise<ApiResponse<T.IndicesPutTemplateResponse, TContext>>;
|
|
1287
|
+
/** @deprecated use putIndexTemplate instead */
|
|
1276
1288
|
putTemplate<TContext = unknown>(
|
|
1277
1289
|
params: T.IndicesPutTemplateRequest,
|
|
1278
1290
|
callback: callbackFn<T.IndicesPutTemplateResponse, TContext>
|
|
1279
1291
|
): TransportRequestCallback;
|
|
1292
|
+
/** @deprecated use putIndexTemplate instead */
|
|
1280
1293
|
putTemplate<TContext = unknown>(
|
|
1281
1294
|
params: T.IndicesPutTemplateRequest,
|
|
1282
1295
|
options: TransportRequestOptions,
|
|
@@ -1401,17 +1414,21 @@ declare class Client {
|
|
|
1401
1414
|
options: TransportRequestOptions,
|
|
1402
1415
|
callback: callbackFn<T.IndicesSimulateIndexTemplateResponse, TContext>
|
|
1403
1416
|
): TransportRequestCallback;
|
|
1417
|
+
/** @deprecated use simulateIndexTemplate instead */
|
|
1404
1418
|
simulateTemplate<TContext = unknown>(
|
|
1405
1419
|
params?: TODO,
|
|
1406
1420
|
options?: TransportRequestOptions
|
|
1407
1421
|
): TransportRequestPromise<ApiResponse<TODO, TContext>>;
|
|
1422
|
+
/** @deprecated use simulateIndexTemplate instead */
|
|
1408
1423
|
simulateTemplate<TContext = unknown>(
|
|
1409
1424
|
callback: callbackFn<TODO, TContext>
|
|
1410
1425
|
): TransportRequestCallback;
|
|
1426
|
+
/** @deprecated use simulateIndexTemplate instead */
|
|
1411
1427
|
simulateTemplate<TContext = unknown>(
|
|
1412
1428
|
params: TODO,
|
|
1413
1429
|
callback: callbackFn<TODO, TContext>
|
|
1414
1430
|
): TransportRequestCallback;
|
|
1431
|
+
/** @deprecated use simulateIndexTemplate instead */
|
|
1415
1432
|
simulateTemplate<TContext = unknown>(
|
|
1416
1433
|
params: TODO,
|
|
1417
1434
|
options: TransportRequestOptions,
|
package/api/requestParams.d.ts
CHANGED
|
@@ -750,6 +750,13 @@ export interface GetSource extends Generic {
|
|
|
750
750
|
version_type?: 'internal' | 'external' | 'external_gte' | 'force';
|
|
751
751
|
}
|
|
752
752
|
|
|
753
|
+
export interface HttpParams extends Generic {
|
|
754
|
+
path: string;
|
|
755
|
+
querystring?: Record<string, any>;
|
|
756
|
+
headers?: Record<string, any>;
|
|
757
|
+
body?: Record<string, any> | string | Array<string | Record<string, any>>;
|
|
758
|
+
}
|
|
759
|
+
|
|
753
760
|
export interface Index<T = RequestBody> extends Generic {
|
|
754
761
|
id?: string;
|
|
755
762
|
index: string;
|
package/api/types.d.ts
CHANGED
|
@@ -3907,17 +3907,17 @@ export interface MappingFloatRangeProperty extends MappingRangePropertyBase {
|
|
|
3907
3907
|
}
|
|
3908
3908
|
|
|
3909
3909
|
export interface MappingGenericProperty extends MappingDocValuesPropertyBase {
|
|
3910
|
-
analyzer
|
|
3911
|
-
boost
|
|
3912
|
-
fielddata
|
|
3913
|
-
ignore_malformed
|
|
3914
|
-
index
|
|
3915
|
-
index_options
|
|
3916
|
-
norms
|
|
3917
|
-
null_value
|
|
3918
|
-
position_increment_gap
|
|
3919
|
-
search_analyzer
|
|
3920
|
-
term_vector
|
|
3910
|
+
analyzer?: string;
|
|
3911
|
+
boost?: double;
|
|
3912
|
+
fielddata?: IndicesStringFielddata;
|
|
3913
|
+
ignore_malformed?: boolean;
|
|
3914
|
+
index?: boolean;
|
|
3915
|
+
index_options?: MappingIndexOptions;
|
|
3916
|
+
norms?: boolean;
|
|
3917
|
+
null_value?: string;
|
|
3918
|
+
position_increment_gap?: integer;
|
|
3919
|
+
search_analyzer?: string;
|
|
3920
|
+
term_vector?: MappingTermVectorOption;
|
|
3921
3921
|
type: string;
|
|
3922
3922
|
}
|
|
3923
3923
|
|
|
@@ -6,10 +6,11 @@ In this guide, we will look at some advanced index actions that are not covered
|
|
|
6
6
|
Let's create a client instance, and an index named `movies`:
|
|
7
7
|
```javascript
|
|
8
8
|
const { Client } = require('@opensearch-project/opensearch');
|
|
9
|
+
|
|
9
10
|
const client = new Client({
|
|
10
|
-
node: '
|
|
11
|
-
ssl: { rejectUnauthorized: false }
|
|
11
|
+
node: 'http://localhost:9200',
|
|
12
12
|
});
|
|
13
|
+
|
|
13
14
|
client.indices.create({index: 'movies'})
|
|
14
15
|
```
|
|
15
16
|
## API Actions
|