@opensearch-project/opensearch 2.1.0 → 2.2.1
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/.eslintrc.json +4 -1
- package/CHANGELOG.md +125 -6
- package/DEVELOPER_GUIDE.md +55 -5
- package/MAINTAINERS.md +10 -6
- package/RELEASING.md +8 -1
- package/USER_GUIDE.md +133 -63
- package/api/api/bulk.js +23 -0
- package/api/api/cat.js +319 -0
- package/api/api/clear_scroll.js +14 -0
- package/api/api/cluster.js +237 -0
- package/api/api/count.js +28 -0
- package/api/api/create.js +26 -0
- package/api/api/create_pit.js +88 -0
- package/api/api/dangling_indices.js +45 -0
- package/api/api/delete.js +23 -0
- package/api/api/delete_all_pits.js +53 -0
- package/api/api/delete_by_query.js +48 -0
- package/api/api/delete_by_query_rethrottle.js +14 -0
- package/api/api/delete_pit.js +61 -0
- package/api/api/delete_script.js +14 -0
- package/api/api/exists.js +25 -0
- package/api/api/exists_source.js +25 -0
- package/api/api/explain.js +27 -0
- package/api/api/features.js +24 -0
- package/api/api/field_caps.js +19 -0
- package/api/api/get.js +25 -0
- package/api/api/get_all_pits.js +53 -0
- package/api/api/get_script.js +16 -0
- package/api/api/get_script_context.js +11 -0
- package/api/api/get_script_languages.js +11 -0
- package/api/api/get_source.js +25 -0
- package/api/api/index.js +29 -0
- package/api/api/indices.js +815 -0
- package/api/api/info.js +11 -0
- package/api/api/ingest.js +89 -0
- package/api/api/mget.js +24 -0
- package/api/api/msearch.js +22 -0
- package/api/api/msearch_template.js +19 -0
- package/api/api/nodes.js +91 -0
- package/api/api/ping.js +11 -0
- package/api/api/put_script.js +17 -0
- package/api/api/rank_eval.js +19 -0
- package/api/api/reindex.js +22 -0
- package/api/api/reindex_rethrottle.js +14 -0
- package/api/api/render_search_template.js +14 -0
- package/api/api/scripts_painless_execute.js +13 -0
- package/api/api/scroll.js +17 -0
- package/api/api/search.js +60 -0
- package/api/api/search_shards.js +19 -0
- package/api/api/search_template.js +27 -0
- package/api/api/shutdown.js +3 -0
- package/api/api/snapshot.js +210 -0
- package/api/api/tasks.js +56 -0
- package/api/api/terms_enum.js +1 -0
- package/api/api/termvectors.js +26 -0
- package/api/api/update.js +28 -0
- package/api/api/update_by_query.js +50 -0
- package/api/api/update_by_query_rethrottle.js +14 -0
- package/api/index.js +28 -0
- package/api/new.d.ts +64 -0
- package/api/opensearch_dashboards.d.ts +4 -0
- package/api/requestParams.d.ts +16 -0
- package/api/types.d.ts +53 -6
- package/guides/advanced_index_actions.md +91 -0
- package/guides/bulk.md +166 -0
- package/guides/document_lifecycle.md +162 -0
- package/guides/index_lifecycle.md +152 -0
- package/guides/index_template.md +228 -0
- package/guides/search.md +217 -0
- package/index.d.ts +160 -0
- package/jenkins/release.JenkinsFile +2 -2
- package/lib/Connection.js +1 -1
- package/lib/Serializer.js +2 -2
- package/lib/Transport.js +23 -1
- package/lib/aws/AwsSigv4Signer.js +14 -5
- package/lib/aws/index.d.ts +1 -0
- package/lib/errors.d.ts +2 -2
- package/lib/errors.js +2 -2
- package/lib/pool/BaseConnectionPool.js +18 -9
- package/lib/pool/CloudConnectionPool.js +2 -2
- package/lib/pool/ConnectionPool.js +4 -4
- package/lib/pool/index.d.ts +35 -6
- package/package.json +13 -12
package/.eslintrc.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,143 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
|
+
|
|
2
3
|
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
3
4
|
|
|
4
5
|
## [Unreleased]
|
|
6
|
+
|
|
5
7
|
### Added
|
|
6
|
-
- Github workflow for changelog verification ([#306](https://github.com/opensearch-project/opensearch-js/pull/306))
|
|
7
|
-
- Add GitHub and Jenkins release workflow ([#317](https://github.com/opensearch-project/opensearch-js/pull/317))
|
|
8
8
|
### Dependencies
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
### Changed
|
|
10
|
+
### Deprecated
|
|
11
|
+
### Removed
|
|
12
|
+
### Fixed
|
|
13
|
+
### Security
|
|
14
|
+
|
|
15
|
+
## [2.2.1]
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Add release details to releasing.md ([319](https://github.com/opensearch-project/opensearch-js/pull/319))
|
|
20
|
+
- Added Amazon OpenSearch Serverless in user_guide ([#372](https://github.com/opensearch-project/opensearch-js/issues/372))
|
|
21
|
+
- Add guidelines on installing yarn, dependencies; instructions on running ESLint in developer_guide ([#439](https://github.com/opensearch-project/opensearch-js/issues/435))
|
|
22
|
+
- Added pull_request_template ([440](https://github.com/opensearch-project/opensearch-js/pull/440))
|
|
23
|
+
- Added guide for Search ([#473](https://github.com/opensearch-project/opensearch-js/pull/489))
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
- Bumps `aws4` from 1.11.0 to 1.12.0
|
|
28
|
+
- Bumps `minimist` from 1.2.6 to 1.2.8
|
|
29
|
+
- Bumps `tsd` from 0.24.1 to 0.27.0
|
|
30
|
+
- Bumps `dezalgo` from 1.0.3 to 1.0.4
|
|
31
|
+
- Bumps `simple-statistics` from 7.7.0 to 7.8.3
|
|
32
|
+
- Bumps `eslint` from 8.30.0 to 8.38.0
|
|
33
|
+
- Downgrades `@types/node` from 18.11.19 to 17.0.45
|
|
34
|
+
- Bumps `ora` from 5.4.1 to 6.1.2
|
|
35
|
+
- Bumps `@aws-sdk/types` from 3.190.0 to 3.257.0
|
|
36
|
+
- Bumps `secure-json-parse` from 2.4.0 to 2.7.0
|
|
37
|
+
- Bumps `simple-git` from 3.15.1 to 3.17.0
|
|
38
|
+
- Bumps `deepmerge` from 4.2.2 to 4.3.1
|
|
39
|
+
- Bumps `tap` from 16.3.0 to 16.3.4
|
|
40
|
+
- Bumps `rimraf` from 4.1.1 to 5.0.0
|
|
41
|
+
- Bumps `@types/node` from 17.0.45 to 18.15.11
|
|
42
|
+
- Bumps `caniuse-lite` from 1.0.30001249 to 1.0.30001469
|
|
43
|
+
- Bumps `eslint-config-prettier` from 8.6.0 to 8.8.0
|
|
44
|
+
- Bumps `split2` from 4.1.0 to 4.2.0
|
|
45
|
+
- Bumps `prettier` from 2.8.4 to 2.8.7
|
|
46
|
+
- Bumps `jsdoc` from 4.0.0 to 4.0.2
|
|
47
|
+
- Bumps `@babel/eslint-parser` from 7.19.1 to 7.21.3
|
|
11
48
|
|
|
12
49
|
### Changed
|
|
13
50
|
|
|
51
|
+
- Remove test artifacts from gh_pages workflow ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
52
|
+
- Make fields in `BulkOperation` optional to match OpenSearch Bulk API requirements ([#378](https://github.com/opensearch-project/opensearch-js/pull/378))
|
|
53
|
+
- Remove guidance on using npm and switch completely to yarn in developer_guide ([#439](https://github.com/opensearch-project/opensearch-js/issues/435))
|
|
54
|
+
- Change coverage, compatability, integration, integration with unreleased Open Search, node ci, bundler tests not to run on documentation change ([441](https://github.com/opensearch-project/opensearch-js/pull/441))
|
|
55
|
+
- Change the Windows yarn installation troubleshoot steps ([455](https://github.com/opensearch-project/opensearch-js/issues/455))
|
|
56
|
+
- Make `callback` arg in `BaseConnectionPool`, `CloudConnectionPool` and `ConnectionPool` optional ([#451](https://github.com/opensearch-project/opensearch-js/pull/451))
|
|
57
|
+
|
|
14
58
|
### Deprecated
|
|
15
59
|
|
|
60
|
+
- Remove deprecation warnings in bulk.test.js ([#434](https://github.com/opensearch-project/opensearch-js/issues/434))
|
|
61
|
+
|
|
16
62
|
### Removed
|
|
17
63
|
|
|
64
|
+
- Remove waitCluster in Integration Tests ([#422](https://github.com/opensearch-project/opensearch-js/issues/422))
|
|
65
|
+
|
|
18
66
|
### Fixed
|
|
19
|
-
|
|
67
|
+
|
|
68
|
+
- Added missing types for AwsSigv4SignerOptions.service ([#377](https://github.com/opensearch-project/opensearch-js/pull/377))
|
|
69
|
+
- Fixed deprecated folder mapping "./" in the "exports" field module resolution ([#416](https://github.com/opensearch-project/opensearch-js/pull/416))
|
|
20
70
|
|
|
21
71
|
### Security
|
|
22
72
|
|
|
73
|
+
- [CVE-2022-25912] Bumps simple-git from 3.4.0 to 3.15.0 ([#341](https://github.com/opensearch-project/opensearch-js/pull/341))
|
|
74
|
+
|
|
75
|
+
## [2.2.0]
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- Add release details to releasing.md ([319](https://github.com/opensearch-project/opensearch-js/pull/319))
|
|
80
|
+
- Allow overriding the aws service identifier in AwsSigv4Signer ([333](https://github.com/opensearch-project/opensearch-js/pull/333))
|
|
81
|
+
- Added skip-changelog label ([339](https://github.com/opensearch-project/opensearch-js/pull/339))
|
|
82
|
+
- Added jsdoc for documentation generation ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
83
|
+
- Documented Transport#request ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
84
|
+
- Documented all API methods ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
85
|
+
- Added point in time APIs ([#348](https://github.com/opensearch-project/opensearch-js/pull/348))
|
|
86
|
+
- Added support for Amazon OpenSearch Serverless ([#356](https://github.com/opensearch-project/opensearch-js/issues/356))
|
|
87
|
+
- Added required `array` argument when invoking `SerializationError` ([#419](https://github.com/opensearch-project/opensearch-js/pull/419))
|
|
88
|
+
- Removed unnecessary `data` argument when invoking `OpenSearchClientError` ([#421](https://github.com/opensearch-project/opensearch-js/pull/421))
|
|
89
|
+
- Fixed typos in `ConnectionPool` ([#427](https://github.com/opensearch-project/opensearch-js/pull/427))
|
|
90
|
+
- Added the solution for the possible error during yarn installation on Windows OS ([#435](https://github.com/opensearch-project/opensearch-js/issues/435))
|
|
91
|
+
- Added missing `createConnection` method type definition in `BaseConnectionPool` )([#490](https://github.com/opensearch-project/opensearch-js/pull/490))
|
|
92
|
+
|
|
93
|
+
### Dependencies
|
|
94
|
+
|
|
95
|
+
- Bumps `xmlbuilder2` from 2.4.1 to 3.0.2
|
|
96
|
+
- Bumps `minimatch` from 3.0.4 to 3.1.2
|
|
97
|
+
- Bumps `eslint` from 7.32.0 to 8.32.0
|
|
98
|
+
- Replaced `babel-eslint` with `@babel/eslint-parser`
|
|
99
|
+
- Bumps `eslint-plugin-prettier` from 4.0.0 to 4.2.1
|
|
100
|
+
- Bumps `json5` from 2.2.0 to 2.2.3
|
|
101
|
+
- Bumps `split2` from 3.2.2 to 4.1.0
|
|
102
|
+
- Bumps `@types/node` from 15.14.7 to 18.11.19
|
|
103
|
+
- Bumps `prettier` from 2.7.1 to 2.8.4
|
|
104
|
+
- Bumps `hpagent` from 0.1.2 to 1.2.0
|
|
105
|
+
- Bumps `eslint-config-prettier` from 8.5.0 to 8.6.0
|
|
106
|
+
- Bumps `rimraf` from 3.0.2 to 4.1.1
|
|
107
|
+
|
|
108
|
+
### Dependencies
|
|
109
|
+
|
|
110
|
+
### Changed
|
|
111
|
+
|
|
112
|
+
- Remove test artifacts from gh_pages workflow ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
113
|
+
- Make `TimeoutError` and `RequestAbortedError` classes' `meta` argument optional ([#478](https://github.com/opensearch-project/opensearch-js/pull/478/))
|
|
114
|
+
|
|
115
|
+
### Deprecated
|
|
116
|
+
|
|
117
|
+
### Removed
|
|
118
|
+
|
|
119
|
+
### Fixed
|
|
120
|
+
|
|
121
|
+
### Security
|
|
122
|
+
|
|
123
|
+
- [CVE-2022-25912] Bumps simple-git from 3.4.0 to 3.15.0 ([#341](https://github.com/opensearch-project/opensearch-js/pull/341))
|
|
124
|
+
|
|
125
|
+
## [2.1.0]
|
|
126
|
+
|
|
127
|
+
### Added
|
|
128
|
+
|
|
129
|
+
- Github workflow for changelog verification ([#306](https://github.com/opensearch-project/opensearch-js/pull/306))
|
|
130
|
+
- Add GitHub and Jenkins release workflow ([#317](https://github.com/opensearch-project/opensearch-js/pull/317))
|
|
131
|
+
|
|
132
|
+
### Dependencies
|
|
133
|
+
|
|
134
|
+
- Bumps `tsd` from 0.22.0 to 0.24.1
|
|
135
|
+
- Bumps `semver` from 7.3.7 to 7.3.8
|
|
136
|
+
|
|
137
|
+
### Fixed
|
|
138
|
+
|
|
139
|
+
- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
|
|
23
140
|
|
|
24
|
-
[
|
|
141
|
+
[2.1.0]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.1.0
|
|
142
|
+
[2.2.0]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.2.0
|
|
143
|
+
[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.2.0...HEAD
|
package/DEVELOPER_GUIDE.md
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
- [Git Clone OpenSearch Node.js Client Repository](#git-clone-opensearch-nodejs-client-repository)
|
|
4
4
|
- [Install Prerequisites](#install-prerequisites)
|
|
5
5
|
- [Node.js](#nodejs)
|
|
6
|
+
- [Yarn](#yarn)
|
|
6
7
|
- [Docker](#docker)
|
|
8
|
+
- [Installing Dependencies](#installing-dependencies)
|
|
9
|
+
- [Using ESLint](#using-eslint)
|
|
7
10
|
- [Unit Testing](#unit-testing)
|
|
8
11
|
- [Integration Testing](#integration-testing)
|
|
9
12
|
- [Execute integration tests from your terminal](#execute-integration-tests-from-your-terminal)
|
|
@@ -25,30 +28,77 @@ e.g. `git clone https://github.com/[your username]/opensearch-js.git`.
|
|
|
25
28
|
|
|
26
29
|
The minimum supported version of Node.js is v10.
|
|
27
30
|
|
|
31
|
+
#### Yarn
|
|
32
|
+
|
|
33
|
+
This project uses yarn as it's package manager. You can use npm to install yarn:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install --global yarn
|
|
37
|
+
```
|
|
38
|
+
|
|
28
39
|
#### Docker
|
|
29
40
|
|
|
30
41
|
[Docker](https://docs.docker.com/install/) is required for building some OpenSearch artifacts and executing integration tests.
|
|
31
42
|
|
|
43
|
+
### Installing Dependencies
|
|
44
|
+
|
|
45
|
+
To install all the dependencies needed for this project, run
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
yarn install
|
|
49
|
+
```
|
|
50
|
+
There might be an issue on Windows OS:
|
|
51
|
+
```
|
|
52
|
+
yarn. ps1 cannot be loaded because running scripts is disabled on this system
|
|
53
|
+
```
|
|
54
|
+
If this occurs, open Windows PowerShell and run:
|
|
55
|
+
```
|
|
56
|
+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
57
|
+
```
|
|
58
|
+
Agree to the changes.
|
|
59
|
+
Now you can run `yarn install`
|
|
60
|
+
If the problem persists, you can try to open Windows PowerShell as an administrator and run:
|
|
61
|
+
```
|
|
62
|
+
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Using ESLint
|
|
66
|
+
|
|
67
|
+
To do a ESLint check on the project, run:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
yarn run lint
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
To let ESLint to fix errors in your code automatically, run:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
yarn run lint:fix
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This will instruct ESLint to try to fix as many issues as possible. The fixes are made to the actual files themselves and only the remaining unfixed issues are output.
|
|
80
|
+
|
|
81
|
+
Not all problems are fixable using this option, and some of them you will need to fix manually.
|
|
82
|
+
|
|
32
83
|
### Unit Testing
|
|
33
84
|
|
|
34
85
|
Go to your terminal and run:
|
|
35
86
|
|
|
36
87
|
```
|
|
37
88
|
cd folder-path
|
|
38
|
-
|
|
89
|
+
yarn run test:unit
|
|
39
90
|
```
|
|
40
91
|
|
|
41
|
-
To run a specific unit test, you can use the following jest command. `
|
|
92
|
+
To run a specific unit test, you can use the following jest command. `yarn test` will not work.
|
|
42
93
|
|
|
43
94
|
```
|
|
44
95
|
cd folder-path/to/test
|
|
45
96
|
jest TestName
|
|
46
97
|
```
|
|
47
98
|
|
|
48
|
-
If you don't have jest, you can install it via
|
|
99
|
+
If you don't have jest, you can install it via yarn
|
|
49
100
|
|
|
50
101
|
```
|
|
51
|
-
npm i -g jest-cli
|
|
52
102
|
yarn global add jest-cli
|
|
53
103
|
```
|
|
54
104
|
|
|
@@ -69,7 +119,7 @@ If you have not installed docker-compose, you can install it from this [link](ht
|
|
|
69
119
|
|
|
70
120
|
2. Run all integration tests.
|
|
71
121
|
```
|
|
72
|
-
|
|
122
|
+
yarn run test:integration:helpers
|
|
73
123
|
```
|
|
74
124
|
3. Stop and clean containers.
|
|
75
125
|
```
|
package/MAINTAINERS.md
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
This document contains a list of maintainers in this repo. See [opensearch-project/.github/RESPONSIBILITIES.md](https://github.com/opensearch-project/.github/blob/main/RESPONSIBILITIES.md#maintainer-responsibilities) that explains what the role of maintainer means, what maintainers do in this and other repos, and how they should be doing it. If you're interested in contributing, and becoming a maintainer, see [CONTRIBUTING](CONTRIBUTING.md).
|
|
2
4
|
|
|
3
5
|
## Current Maintainers
|
|
4
6
|
|
|
5
7
|
| Maintainer | GitHub ID | Affiliation |
|
|
6
8
|
|-----------------------|-----------------------------------------------|-------------|
|
|
7
9
|
| Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
|
|
8
|
-
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb) | Amazon |
|
|
9
10
|
| Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
|
|
10
|
-
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
|
|
11
11
|
| Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
|
|
12
12
|
| Daniel Doubrovkine | [dblock](https://github.com/dblock) | Amazon |
|
|
13
13
|
| Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon |
|
|
14
14
|
| Theo Truong | [nhtruong](https://github.com/nhtruong) | Amazon |
|
|
15
|
+
| Harsha Vamsi Kalluri | [harshavamsi](https://github.com/harshavamsi) | Amazon |
|
|
16
|
+
|
|
17
|
+
## Emeritus
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
| Maintainer | GitHub ID | Affiliation |
|
|
20
|
+
|---------------|-------------------------------------------|-------------|
|
|
21
|
+
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb) | Amazon |
|
|
22
|
+
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
|
package/RELEASING.md
CHANGED
|
@@ -31,4 +31,11 @@ Repositories create consistent release labels, such as `v1.0.0`, `v1.1.0` and `v
|
|
|
31
31
|
|
|
32
32
|
## Releasing
|
|
33
33
|
|
|
34
|
-
The release process is standard across repositories in this org and is run by a release manager volunteering from amongst [
|
|
34
|
+
The release process is standard across repositories in this org and is run by a release manager volunteering from amongst [maintainers](MAINTAINERS.md).
|
|
35
|
+
|
|
36
|
+
1. Create a tag, e.g. v2.1.0, and push it to the GitHub repo.
|
|
37
|
+
1. The [release-drafter.yml](.github/workflows/release-drafter.yml) will be automatically kicked off and is responsible for drafting a new release on GitHub.
|
|
38
|
+
1. Before creating a draft release, this workflow creates a GitHub issue asking for approval from the [maintainers](MAINTAINERS.md). See sample [issue](https://github.com/gaiksaya/opensearch-js/issues/1). The maintainers need to approve in order to continue the workflow run.
|
|
39
|
+
1. This draft release triggers the [jenkins release workflow](https://build.ci.opensearch.org/job/opensearch-js-release/) as a result of which opensearch-js client is released on [npmjs](https://www.npmjs.com/package/@opensearch-project/opensearch).
|
|
40
|
+
1. Once the above release workflow is successful, the drafted release on GitHub is published automatically.
|
|
41
|
+
1. Increment "version" in package.json to the next patch release, e.g. v2.1.1. See [example](https://github.com/opensearch-project/opensearch-js/pull/318)
|
package/USER_GUIDE.md
CHANGED
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
- [Search for the Document](#search-for-the-document)
|
|
11
11
|
- [Delete the document](#delete-the-document)
|
|
12
12
|
- [Delete the index](#delete-the-index)
|
|
13
|
+
- [Empty all Pool Connections](#empty-all-pool-connections)
|
|
13
14
|
|
|
14
15
|
## Initializing a Client
|
|
16
|
+
|
|
15
17
|
```javascript
|
|
16
18
|
'use strict';
|
|
17
19
|
|
|
@@ -50,7 +52,8 @@ const { AwsSigv4Signer } = require('@opensearch-project/opensearch/aws');
|
|
|
50
52
|
|
|
51
53
|
const client = new Client({
|
|
52
54
|
...AwsSigv4Signer({
|
|
53
|
-
region: 'us-
|
|
55
|
+
region: 'us-west-2',
|
|
56
|
+
service: 'es', // 'aoss' for OpenSearch Serverless
|
|
54
57
|
// Must return a Promise that resolve to an AWS.Credentials object.
|
|
55
58
|
// This function is used to acquire the credentials when the client start and
|
|
56
59
|
// when the credentials are expired.
|
|
@@ -70,20 +73,22 @@ const client = new Client({
|
|
|
70
73
|
});
|
|
71
74
|
}),
|
|
72
75
|
}),
|
|
73
|
-
node:
|
|
76
|
+
node: 'https://search-xxx.region.es.amazonaws.com', // OpenSearch domain URL
|
|
77
|
+
// node: "https://xxx.region.aoss.amazonaws.com" for OpenSearch Serverless
|
|
74
78
|
});
|
|
75
79
|
```
|
|
76
80
|
|
|
77
81
|
#### Using AWS V3 SDK
|
|
78
82
|
|
|
79
83
|
```javascript
|
|
80
|
-
const { defaultProvider } = require(
|
|
84
|
+
const { defaultProvider } = require('@aws-sdk/credential-provider-node'); // V3 SDK.
|
|
81
85
|
const { Client } = require('@opensearch-project/opensearch');
|
|
82
86
|
const { AwsSigv4Signer } = require('@opensearch-project/opensearch/aws');
|
|
83
87
|
|
|
84
88
|
const client = new Client({
|
|
85
89
|
...AwsSigv4Signer({
|
|
86
90
|
region: 'us-east-1',
|
|
91
|
+
service: 'es', // 'aoss' for OpenSearch Serverless
|
|
87
92
|
// Must return a Promise that resolve to an AWS.Credentials object.
|
|
88
93
|
// This function is used to acquire the credentials when the client start and
|
|
89
94
|
// when the credentials are expired.
|
|
@@ -97,101 +102,166 @@ const client = new Client({
|
|
|
97
102
|
return credentialsProvider();
|
|
98
103
|
},
|
|
99
104
|
}),
|
|
100
|
-
node:
|
|
105
|
+
node: 'https://search-xxx.region.es.amazonaws.com', // OpenSearch domain URL
|
|
106
|
+
// node: "https://xxx.region.aoss.amazonaws.com" for OpenSearch Serverless
|
|
101
107
|
});
|
|
102
108
|
```
|
|
103
109
|
|
|
104
110
|
## Create an Index
|
|
105
111
|
|
|
106
112
|
```javascript
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
113
|
+
console.log('Creating index:');
|
|
114
|
+
|
|
115
|
+
var index_name = 'books';
|
|
116
|
+
var settings = {
|
|
117
|
+
settings: {
|
|
118
|
+
index: {
|
|
119
|
+
number_of_shards: 4,
|
|
120
|
+
number_of_replicas: 3,
|
|
116
121
|
},
|
|
117
|
-
}
|
|
122
|
+
},
|
|
123
|
+
};
|
|
118
124
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
var response = await client.indices.create({
|
|
126
|
+
index: index_name,
|
|
127
|
+
body: settings,
|
|
128
|
+
});
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
console.log(response.body);
|
|
125
131
|
```
|
|
126
132
|
|
|
127
133
|
## Add a Document to the Index
|
|
128
134
|
|
|
129
135
|
```javascript
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
136
|
+
console.log('Adding document:');
|
|
137
|
+
|
|
138
|
+
var document = {
|
|
139
|
+
title: 'The Outsider',
|
|
140
|
+
author: 'Stephen King',
|
|
141
|
+
year: '2018',
|
|
142
|
+
genre: 'Crime fiction',
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
var id = '1';
|
|
146
|
+
|
|
147
|
+
var response = await client.index({
|
|
148
|
+
id: id,
|
|
149
|
+
index: index_name,
|
|
150
|
+
body: document,
|
|
151
|
+
refresh: true,
|
|
152
|
+
});
|
|
147
153
|
|
|
148
|
-
|
|
154
|
+
console.log(response.body);
|
|
149
155
|
```
|
|
150
156
|
|
|
151
157
|
## Search for the Document
|
|
152
158
|
|
|
153
159
|
```javascript
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
},
|
|
160
|
+
console.log('Search results:');
|
|
161
|
+
|
|
162
|
+
var query = {
|
|
163
|
+
query: {
|
|
164
|
+
match: {
|
|
165
|
+
title: {
|
|
166
|
+
query: 'The Outsider',
|
|
162
167
|
},
|
|
163
168
|
},
|
|
164
|
-
}
|
|
169
|
+
},
|
|
170
|
+
};
|
|
165
171
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
var response = await client.search({
|
|
173
|
+
index: index_name,
|
|
174
|
+
body: query,
|
|
175
|
+
});
|
|
170
176
|
|
|
171
|
-
|
|
177
|
+
console.log(response.body.hits);
|
|
172
178
|
```
|
|
173
179
|
|
|
174
180
|
## Delete the document
|
|
175
181
|
|
|
176
182
|
```javascript
|
|
177
|
-
|
|
183
|
+
console.log('Deleting document:');
|
|
178
184
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
var response = await client.delete({
|
|
186
|
+
index: index_name,
|
|
187
|
+
id: id,
|
|
188
|
+
});
|
|
183
189
|
|
|
184
|
-
|
|
190
|
+
console.log(response.body);
|
|
185
191
|
```
|
|
186
192
|
|
|
187
193
|
## Delete the index
|
|
188
194
|
|
|
189
195
|
```javascript
|
|
190
|
-
|
|
196
|
+
console.log('Deleting index:');
|
|
197
|
+
|
|
198
|
+
var response = await client.indices.delete({
|
|
199
|
+
index: index_name,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
console.log(response.body);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Create a Point in Time
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
console.log('Creating a PIT:');
|
|
209
|
+
|
|
210
|
+
var response = await client.createPit({
|
|
211
|
+
index: 'books*',
|
|
212
|
+
keep_alive: '100m',
|
|
213
|
+
expand_wildcards: 'all',
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
console.log(response.body);
|
|
217
|
+
```
|
|
191
218
|
|
|
192
|
-
|
|
193
|
-
index: index_name,
|
|
194
|
-
});
|
|
219
|
+
## Get all PITs
|
|
195
220
|
|
|
196
|
-
|
|
197
|
-
|
|
221
|
+
```javascript
|
|
222
|
+
console.log('Getting all PITs:');
|
|
223
|
+
|
|
224
|
+
var response = await client.getAllPits();
|
|
225
|
+
|
|
226
|
+
console.log(response.body);
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Delete a Point in Time
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
console.log('Deleting a PIT:');
|
|
233
|
+
|
|
234
|
+
var response = await client.deletePit({
|
|
235
|
+
body: {
|
|
236
|
+
pit_id: [
|
|
237
|
+
'o463QQEPbXktaW5kZXgtMDAwMDAxFkhGN09fMVlPUkVPLXh6MUExZ1hpaEEAFjBGbmVEZHdGU1EtaFhhUFc4ZkR5cWcAAAAAAAAAAAEWaXBPNVJtZEhTZDZXTWFFR05waXdWZwEWSEY3T18xWU9SRU8teHoxQTFnWGloQQAA',
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
console.log(response.body);
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Delete all PITs
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
console.log('Deleting all PITs:');
|
|
249
|
+
|
|
250
|
+
var response = await client.deleteAllPits();
|
|
251
|
+
|
|
252
|
+
console.log(response.body);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Empty all Pool Connections
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
var pool = new ConnectionPool({ Connection });
|
|
259
|
+
pool.addConnection('http://localhost:9200/');
|
|
260
|
+
pool.addConnection('http://localhost:9201/');
|
|
261
|
+
|
|
262
|
+
pool.empty();
|
|
263
|
+
// OR
|
|
264
|
+
pool.empty(() => {
|
|
265
|
+
// Do something after emptying the pool
|
|
266
|
+
});
|
|
267
|
+
```
|
package/api/api/bulk.js
CHANGED
|
@@ -63,6 +63,29 @@ const snakeCase = {
|
|
|
63
63
|
filterPath: 'filter_path',
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The bulk operation lets you add, update, or delete many documents in a single request.
|
|
68
|
+
* Compared to individual OpenSearch indexing requests, the bulk operation has significant performance benefits.
|
|
69
|
+
* Whenever practical, we recommend batching indexing operations into bulk requests.
|
|
70
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/document-apis/bulk/|OpenSearch - Bulk}
|
|
71
|
+
*
|
|
72
|
+
* @memberOf API-Document
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} params
|
|
75
|
+
* @param {Object[]} params.body - {@link https://opensearch.org/docs/latest/api-reference/document-apis/bulk/#request-body|Request Body}
|
|
76
|
+
* @param {string} [params.index] - Specifying the index means you don’t need to include it in the request body.
|
|
77
|
+
* @param {string} [params.pipeline] - The pipeline ID for preprocessing documents.
|
|
78
|
+
* @param {string} [params.routing] - Routes the request to the specified shard.
|
|
79
|
+
* @param {string} [params.refresh=false] - If true, OpenSearch refreshes shards to make the operation visible to searching. Valid options are 'true', 'false', and 'wait_for', which tells OpenSearch to wait for a refresh before executing the operation.
|
|
80
|
+
* @param {string} [params.timeout=1m] - How long to wait for a response from the cluster.
|
|
81
|
+
* @param {string} [params.wait_for_active_shards] - The number of active shards that must be available before OpenSearch processes the request. Default is 1 (only the primary shard). Set to all or a positive integer. Values greater than 1 require replicas. For example, if you specify a value of 3, the index must have two replicas distributed across two additional nodes for the operation to succeed.
|
|
82
|
+
* @param {boolean} [params.require_alias=false] - Specifies whether the target index must be an index alias.
|
|
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>|*} {@link https://opensearch.org/docs/latest/api-reference/document-apis/bulk/#response|Bulk Response}
|
|
88
|
+
*/
|
|
66
89
|
function bulkApi(params, options, callback) {
|
|
67
90
|
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
68
91
|
|