@opensearch-project/opensearch 2.0.0 → 2.2.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/.eslintrc.json +13 -5
- package/ADMINS.md +13 -38
- package/CHANGELOG.md +54 -0
- package/COMPATIBILITY.md +4 -1
- package/MAINTAINERS.md +11 -73
- package/Makefile +2 -12
- package/README.md +4 -107
- package/RELEASING.md +7 -1
- package/USER_GUIDE.md +248 -0
- package/api/api/bulk.js +24 -2
- package/api/api/cat.js +320 -2
- package/api/api/clear_scroll.js +15 -2
- package/api/api/cluster.js +238 -2
- package/api/api/count.js +29 -2
- package/api/api/create.js +27 -2
- package/api/api/create_pit.js +88 -0
- package/api/api/dangling_indices.js +46 -2
- package/api/api/delete.js +24 -2
- package/api/api/delete_all_pits.js +53 -0
- package/api/api/delete_by_query.js +49 -2
- package/api/api/delete_by_query_rethrottle.js +15 -2
- package/api/api/delete_pit.js +61 -0
- package/api/api/delete_script.js +15 -2
- package/api/api/exists.js +26 -2
- package/api/api/exists_source.js +26 -2
- package/api/api/explain.js +28 -2
- package/api/api/features.js +25 -2
- package/api/api/field_caps.js +20 -2
- package/api/api/get.js +26 -2
- package/api/api/get_all_pits.js +53 -0
- package/api/api/get_script.js +17 -2
- package/api/api/get_script_context.js +12 -2
- package/api/api/get_script_languages.js +12 -2
- package/api/api/get_source.js +26 -2
- package/api/api/index.js +30 -2
- package/api/api/indices.js +816 -2
- package/api/api/info.js +12 -2
- package/api/api/ingest.js +90 -2
- package/api/api/mget.js +25 -2
- package/api/api/msearch.js +23 -2
- package/api/api/msearch_template.js +20 -2
- package/api/api/mtermvectors.js +1 -2
- package/api/api/nodes.js +92 -2
- package/api/api/ping.js +12 -2
- package/api/api/put_script.js +18 -2
- package/api/api/rank_eval.js +20 -2
- package/api/api/reindex.js +23 -2
- package/api/api/reindex_rethrottle.js +15 -2
- package/api/api/render_search_template.js +15 -2
- package/api/api/scripts_painless_execute.js +14 -2
- package/api/api/scroll.js +18 -2
- package/api/api/search.js +61 -2
- package/api/api/search_shards.js +20 -2
- package/api/api/search_template.js +28 -2
- package/api/api/shutdown.js +4 -2
- package/api/api/snapshot.js +211 -2
- package/api/api/tasks.js +57 -2
- package/api/api/terms_enum.js +2 -2
- package/api/api/termvectors.js +27 -2
- package/api/api/update.js +29 -2
- package/api/api/update_by_query.js +51 -2
- package/api/api/update_by_query_rethrottle.js +15 -2
- package/api/index.js +29 -2
- package/api/new.d.ts +65 -2
- package/api/opensearch_dashboards.d.ts +5 -2
- package/api/requestParams.d.ts +17 -2
- package/api/types.d.ts +48 -2
- package/api/utils.js +1 -2
- package/index.d.ts +605 -120
- package/index.js +2 -3
- package/index.mjs +1 -2
- package/jenkins/release.JenkinsFile +11 -0
- package/lib/Connection.d.ts +1 -2
- package/lib/Connection.js +5 -4
- package/lib/Helpers.d.ts +5 -4
- package/lib/Helpers.js +13 -17
- package/lib/Serializer.d.ts +1 -2
- package/lib/Serializer.js +2 -3
- package/lib/Transport.d.ts +10 -4
- package/lib/Transport.js +34 -7
- package/lib/aws/AwsSigv4Signer.js +176 -0
- package/lib/aws/errors.js +24 -0
- package/lib/aws/index.d.ts +39 -0
- package/lib/aws/index.js +19 -0
- package/lib/errors.d.ts +1 -2
- package/lib/errors.js +1 -2
- package/lib/pool/BaseConnectionPool.js +1 -2
- package/lib/pool/CloudConnectionPool.js +1 -2
- package/lib/pool/ConnectionPool.js +1 -2
- package/lib/pool/index.d.ts +1 -2
- package/lib/pool/index.js +1 -2
- package/package.json +36 -18
package/.eslintrc.json
CHANGED
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
"eslint:recommended",
|
|
8
8
|
"prettier"
|
|
9
9
|
],
|
|
10
|
-
"parser": "babel-
|
|
10
|
+
"parser": "@babel/eslint-parser",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"requireConfigFile": false
|
|
13
|
+
},
|
|
11
14
|
"plugins": [
|
|
12
15
|
"prettier"
|
|
13
16
|
],
|
|
@@ -18,9 +21,14 @@
|
|
|
18
21
|
"endOfLine": "auto"
|
|
19
22
|
}
|
|
20
23
|
],
|
|
21
|
-
/*temporarily turn off no-unused-vars, open an issue to track https://github.com/opensearch-project/opensearch-js/issues/241*/
|
|
22
|
-
"no-unused-vars": "off",
|
|
23
24
|
/*temporarily turn off no-dupe-else-if, open an issue to track https://github.com/opensearch-project/opensearch-js/issues/240*/
|
|
24
|
-
"no-dupe-else-if": "off"
|
|
25
|
+
"no-dupe-else-if": "off",
|
|
26
|
+
"no-unused-vars": [
|
|
27
|
+
"error",
|
|
28
|
+
{
|
|
29
|
+
"varsIgnorePattern": "^_.*",
|
|
30
|
+
"argsIgnorePattern": "^_.*"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
25
33
|
}
|
|
26
|
-
}
|
|
34
|
+
}
|
package/ADMINS.md
CHANGED
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
- [Current Admins](#current-admins)
|
|
3
|
-
- [Admin Responsibilities](#admin-responsibilities)
|
|
4
|
-
- [Prioritize Security](#prioritize-security)
|
|
5
|
-
- [Enforce Code of Conduct](#enforce-code-of-conduct)
|
|
6
|
-
- [Adopt Organizational Best Practices](#adopt-organizational-best-practices)
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
This document explains who the admins are (see below), what they do in this repo, and how they should be doing it. If you're interested in becoming a maintainer, see [MAINTAINERS](MAINTAINERS.md). If you're interested in contributing, see [CONTRIBUTING](CONTRIBUTING.md).
|
|
1
|
+
# OpenSearch JavaScript Client Admins
|
|
11
2
|
|
|
12
3
|
## Current Admins
|
|
13
4
|
|
|
14
|
-
| Admin | GitHub ID
|
|
15
|
-
|
|
16
|
-
| Anan Zhuang | [ananzh](https://github.com/ananzh)
|
|
17
|
-
| Bishoy Boktor | [boktorbb
|
|
18
|
-
| Charlotte | [CEHENKLE](https://github.com/CEHENKLE)
|
|
19
|
-
| Henri Yandell | [hyandell](https://github.com/hyandell)
|
|
20
|
-
| Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla)
|
|
21
|
-
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni)
|
|
22
|
-
| Sean Neumann | [seanneumann](https://github.com/seanneumann)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
As an admin you own stewartship of the repository and its settings. Admins have [admin-level permissions on a repository](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-permission-levels-for-an-organization). Use those privileges to serve the community and protect the repository as follows.
|
|
28
|
-
|
|
29
|
-
### Prioritize Security
|
|
30
|
-
|
|
31
|
-
Security is your number one priority. Manage security keys and safeguard access to the repository.
|
|
32
|
-
|
|
33
|
-
Note that this repository is monitored and supported 24/7 by Amazon Security, see [Reporting a Vulnerability](SECURITY.md) for details.
|
|
34
|
-
|
|
35
|
-
### Enforce Code of Conduct
|
|
36
|
-
|
|
37
|
-
Act on [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) violations by revoking access, and blocking malicious actors.
|
|
38
|
-
|
|
39
|
-
### Adopt Organizational Best Practices
|
|
40
|
-
|
|
41
|
-
Adopt organizational best practices, work in the open, and collaborate with other admins by opening issues before making process changes. Prefer consistency, and avoid diverging from practices in the opensearch-project organization.
|
|
5
|
+
| Admin | GitHub ID | Affiliation |
|
|
6
|
+
|-----------------------|-----------------------------------------------|-------------|
|
|
7
|
+
| Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
|
|
8
|
+
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb) | Amazon |
|
|
9
|
+
| Charlotte | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
|
|
10
|
+
| Henri Yandell | [hyandell](https://github.com/hyandell) | Amazon |
|
|
11
|
+
| Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
|
|
12
|
+
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
|
|
13
|
+
| Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
|
|
14
|
+
|
|
15
|
+
[This document](https://github.com/opensearch-project/.github/blob/main/ADMINS.md)
|
|
16
|
+
explains what an admin's responsibilities are.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
3
|
+
|
|
4
|
+
## [Unreleased]
|
|
5
|
+
### Added
|
|
6
|
+
- Add release details to releasing.md ([319](https://github.com/opensearch-project/opensearch-js/pull/319))
|
|
7
|
+
- Allow overriding the aws service identifier in AwsSigv4Signer ([333](https://github.com/opensearch-project/opensearch-js/pull/333))
|
|
8
|
+
- Added skip-changelog label ([339](https://github.com/opensearch-project/opensearch-js/pull/339))
|
|
9
|
+
- Added jsdoc for documentation generation ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
10
|
+
- Documented Transport#request ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
11
|
+
- Documented all API methods ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
12
|
+
- Added point in time APIs ([#348](https://github.com/opensearch-project/opensearch-js/pull/348))
|
|
13
|
+
- Added support for Amazon OpenSearch Serverless ([#356](https://github.com/opensearch-project/opensearch-js/issues/356))
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
- Bumps `xmlbuilder2` from 2.4.1 to 3.0.2
|
|
17
|
+
- Bumps `minimatch` from 3.0.4 to 3.1.2
|
|
18
|
+
- Bumps `eslint` from 8.30.0 to 8.32.0
|
|
19
|
+
- Bumps `eslint` from 7.32.0 to 8.32.0
|
|
20
|
+
- Replaced `babel-eslint` with `@babel/eslint-parser`
|
|
21
|
+
- Bumps `eslint-plugin-prettier` from 4.0.0 to 4.2.1
|
|
22
|
+
- Bumps `minimist` from 1.2.6 to 1.2.7
|
|
23
|
+
- Bumps `@aws-sdk/types` from 3.190.0 to 3.226.0
|
|
24
|
+
- Bumps `json5` from 2.2.0 to 2.2.3
|
|
25
|
+
- Bumps `split2` from 3.2.2 to 4.1.0
|
|
26
|
+
- Bumps `@types/node` from 15.14.7 to 18.11.18
|
|
27
|
+
- Bumps `prettier` from 2.7.1 to 2.8.3
|
|
28
|
+
- Bumps `hpagent` from 0.1.2 to 1.2.0
|
|
29
|
+
- Bumps `eslint-config-prettier` from 8.5.0 to 8.6.0
|
|
30
|
+
- Bumps `rimraf` from 3.0.2 to 4.1.1
|
|
31
|
+
|
|
32
|
+
### Dependencies
|
|
33
|
+
### Changed
|
|
34
|
+
- Remove test artifacts from gh_pages workflow ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
|
|
35
|
+
### Deprecated
|
|
36
|
+
### Removed
|
|
37
|
+
### Fixed
|
|
38
|
+
### Security
|
|
39
|
+
- [CVE-2022-25912] Bumps simple-git from 3.4.0 to 3.15.0 ([#341](https://github.com/opensearch-project/opensearch-js/pull/341))
|
|
40
|
+
|
|
41
|
+
## [2.1]
|
|
42
|
+
### Added
|
|
43
|
+
- Github workflow for changelog verification ([#306](https://github.com/opensearch-project/opensearch-js/pull/306))
|
|
44
|
+
- Add GitHub and Jenkins release workflow ([#317](https://github.com/opensearch-project/opensearch-js/pull/317))
|
|
45
|
+
|
|
46
|
+
### Dependencies
|
|
47
|
+
- Bumps `tsd` from 0.22.0 to 0.24.1
|
|
48
|
+
- Bumps `semver` from 7.3.7 to 7.3.8
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
|
|
52
|
+
|
|
53
|
+
[2.1]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.1.0
|
|
54
|
+
[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.1...HEAD
|
package/COMPATIBILITY.md
CHANGED
|
@@ -17,8 +17,11 @@ The below matrix shows the compatibility of the [`opensearch-js`](https://www.np
|
|
|
17
17
|
| 1.2.4 | 1.1.0 |
|
|
18
18
|
| 1.3.0 | 1.1.0 |
|
|
19
19
|
| 1.3.1 | 1.1.0 |
|
|
20
|
+
| 1.3.2 | 1.1.0 |
|
|
21
|
+
| 1.3.3 | 1.1.0 |
|
|
20
22
|
| 2.0.0 | 2.0.0 |
|
|
23
|
+
| 2.0.1 | 2.0.0 |
|
|
21
24
|
|
|
22
25
|
## Upgrading
|
|
23
26
|
|
|
24
|
-
Major versions of OpenSearch introduce breaking changes that require careful upgrades of the client. While `opensearch-js` 2.0.0 works against OpenSearch 1.
|
|
27
|
+
Major versions of OpenSearch introduce breaking changes that require careful upgrades of the client. While `opensearch-js` 2.0.0 works against the latest OpenSearch 1.x, certain deprecated features removed in OpenSearch 2.0 have also been removed from the client. Please refer to the [OpenSearch documentation](https://opensearch.org/docs/latest/clients/index/) for more information.
|
package/MAINTAINERS.md
CHANGED
|
@@ -1,78 +1,16 @@
|
|
|
1
|
-
- [Overview](#overview)
|
|
2
|
-
- [Current Maintainers](#current-maintainers)
|
|
3
|
-
- [Maintainer Responsibilities](#maintainer-responsibilities)
|
|
4
|
-
- [Uphold Code of Conduct](#uphold-code-of-conduct)
|
|
5
|
-
- [Prioritize Security](#prioritize-security)
|
|
6
|
-
- [Review Pull Requests](#review-pull-requests)
|
|
7
|
-
- [Triage Open Issues](#triage-open-issues)
|
|
8
|
-
- [Backports](#backports)
|
|
9
|
-
- [Be Responsive](#be-responsive)
|
|
10
|
-
- [Maintain Overall Health of the Repo](#maintain-overall-health-of-the-repo)
|
|
11
|
-
- [Use Semver](#use-semver)
|
|
12
|
-
- [Release Frequently](#release-frequently)
|
|
13
|
-
- [Promote Other Maintainers](#promote-other-maintainers)
|
|
14
|
-
|
|
15
1
|
## Overview
|
|
16
2
|
|
|
17
|
-
This document
|
|
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).
|
|
18
4
|
|
|
19
5
|
## Current Maintainers
|
|
20
6
|
|
|
21
|
-
| Maintainer | GitHub ID
|
|
22
|
-
| --------------------- |
|
|
23
|
-
| Anan Zhuang | [ananzh](https://github.com/ananzh)
|
|
24
|
-
| Bishoy Boktor | [boktorbb
|
|
25
|
-
| Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla)
|
|
26
|
-
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni)
|
|
27
|
-
| Sean Neumann | [seanneumann](https://github.com/seanneumann)
|
|
28
|
-
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Maintainers are active and visible members of the community, and have [maintain-level permissions on a repository](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-permission-levels-for-an-organization). Use those privileges to serve the community and evolve code as follows.
|
|
33
|
-
|
|
34
|
-
### Uphold Code of Conduct
|
|
35
|
-
|
|
36
|
-
Model the behavior set forward by the [Code of Conduct](CODE_OF_CONDUCT.md) and raise any violations to other maintainers and admins.
|
|
37
|
-
|
|
38
|
-
### Prioritize Security
|
|
39
|
-
|
|
40
|
-
Security is your number one priority. Maintainer's Github keys must be password protected securely and any reported security vulnerabilities are addressed before features or bugs.
|
|
41
|
-
|
|
42
|
-
Note that this repository is monitored and supported 24/7 by Amazon Security, see [Reporting a Vulnerability](SECURITY.md) for details.
|
|
43
|
-
|
|
44
|
-
### Review Pull Requests
|
|
45
|
-
|
|
46
|
-
Review pull requests regularly, comment, suggest, reject, merge and close. Accept only high quality pull-requests. Provide code reviews and guidance on incomming pull requests. Don't let PRs be stale and do your best to be helpful to contributors.
|
|
47
|
-
|
|
48
|
-
### Triage Open Issues
|
|
49
|
-
|
|
50
|
-
Manage labels, review issues regularly, and triage by labelling them.
|
|
51
|
-
|
|
52
|
-
All repositories in this organization have a standard set of labels, including `bug`, `documentation`, `duplicate`, `enhancement`, `good first issue`, `help wanted`, `blocker`, `invalid`, `question`, `wontfix`, and `untriaged`, along with release labels, such as `v1.0.0`, `v1.1.0` and `v2.0.0`, and `backport`.
|
|
53
|
-
|
|
54
|
-
Use labels to target an issue or a PR for a given release, add `help wanted` to good issues for new community members, and `blocker` for issues that scare you or need immediate attention. Request for more information from a submitter if an issue is not clear. Create new labels as needed by the project.
|
|
55
|
-
|
|
56
|
-
### Backports
|
|
57
|
-
|
|
58
|
-
The Github workflow in [backport.yml](.github/workflows/backport.yml) creates backport PRs automatically when the original PR with an appropriate label `backport <backport-branch-name>` is merged to main. To backport a PR to `1.x`, add a label `backport 1.x` to the PR, once this PR is merged to main, the workflow will create a backport PR to the `1.x` branch.
|
|
59
|
-
|
|
60
|
-
### Be Responsive
|
|
61
|
-
|
|
62
|
-
Respond to enhancement requests, and forum posts. Allocate time to reviewing and commenting on issues and conversations as they come in.
|
|
63
|
-
|
|
64
|
-
### Maintain Overall Health of the Repo
|
|
65
|
-
|
|
66
|
-
Keep the `main` branch at production quality at all times. Backport features as needed. Cut release branches and tags to enable future patches.
|
|
67
|
-
|
|
68
|
-
### Use Semver
|
|
69
|
-
|
|
70
|
-
Use and enforce [semantic versioning](https://semver.org/) and do not let breaking changes be made outside of major releases.
|
|
71
|
-
|
|
72
|
-
### Release Frequently
|
|
73
|
-
|
|
74
|
-
Make frequent project releases to the community.
|
|
75
|
-
|
|
76
|
-
### Promote Other Maintainers
|
|
77
|
-
|
|
78
|
-
Assist, add, and remove [MAINTAINERS](MAINTAINERS.md). Exercise good judgement, and propose high quality contributors to become co-maintainers.
|
|
7
|
+
| Maintainer | GitHub ID | Affiliation |
|
|
8
|
+
| --------------------- | --------------------------------------------- | ----------- |
|
|
9
|
+
| Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
|
|
10
|
+
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb) | Amazon |
|
|
11
|
+
| Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
|
|
12
|
+
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
|
|
13
|
+
| Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
|
|
14
|
+
| Daniel Doubrovkine | [dblock](https://github.com/dblock) | Amazon |
|
|
15
|
+
| Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon |
|
|
16
|
+
| Theo Truong | [nhtruong](https://github.com/nhtruong) | Amazon |
|
package/Makefile
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
cluster.opendistro.build:
|
|
2
|
-
docker-compose --project-directory .ci/opendistro build;
|
|
3
|
-
|
|
4
|
-
cluster.opendistro.start:
|
|
5
|
-
docker-compose --project-directory .ci/opendistro up -d ;
|
|
6
|
-
sleep 20;
|
|
7
|
-
|
|
8
|
-
cluster.opendistro.stop:
|
|
9
|
-
docker-compose --project-directory .ci/opendistro down ;
|
|
10
|
-
|
|
11
1
|
cluster.opensearch.build:
|
|
12
2
|
docker-compose --project-directory .ci/opensearch build;
|
|
13
3
|
|
|
14
4
|
cluster.opensearch.start:
|
|
15
5
|
docker-compose --project-directory .ci/opensearch up -d ;
|
|
16
|
-
sleep
|
|
6
|
+
sleep 60;
|
|
17
7
|
|
|
18
8
|
cluster.opensearch.stop:
|
|
19
9
|
docker-compose --project-directory .ci/opensearch down ;
|
|
@@ -24,4 +14,4 @@ cluster.clean: ## Remove unused Docker volumes and networks
|
|
|
24
14
|
docker network prune --force
|
|
25
15
|
docker system prune --volumes --force
|
|
26
16
|
|
|
27
|
-
.PHONY: cluster.
|
|
17
|
+
.PHONY: cluster.opensearch.build cluster.opensearch.start cluster.opensearch.stop cluster.clean
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ OpenSearch Node.js client
|
|
|
12
12
|
- [Welcome!](#welcome)
|
|
13
13
|
- [Example use](#example-use)
|
|
14
14
|
- [Setup](#setup)
|
|
15
|
-
|
|
15
|
+
- [Sample code](#sample-code)
|
|
16
16
|
- [Project Resources](#project-resources)
|
|
17
17
|
- [Code of Conduct](#code-of-conduct)
|
|
18
18
|
- [License](#license)
|
|
@@ -44,113 +44,10 @@ Then require the client:
|
|
|
44
44
|
const { Client } = require('@opensearch-project/opensearch');
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
## Sample code
|
|
48
|
+
|
|
49
|
+
Please see the [USER_GUIDE](USER_GUIDE.md) for code snippets.
|
|
48
50
|
|
|
49
|
-
```javascript
|
|
50
|
-
'use strict';
|
|
51
|
-
|
|
52
|
-
var host = 'localhost';
|
|
53
|
-
var protocol = 'https';
|
|
54
|
-
var port = 9200;
|
|
55
|
-
var auth = 'admin:admin'; // For testing only. Don't store credentials in code.
|
|
56
|
-
var ca_certs_path = '/full/path/to/root-ca.pem';
|
|
57
|
-
|
|
58
|
-
// Optional client certificates if you don't want to use HTTP basic authentication.
|
|
59
|
-
// var client_cert_path = '/full/path/to/client.pem'
|
|
60
|
-
// var client_key_path = '/full/path/to/client-key.pem'
|
|
61
|
-
|
|
62
|
-
// Create a client with SSL/TLS enabled.
|
|
63
|
-
var { Client } = require('@opensearch-project/opensearch');
|
|
64
|
-
var fs = require('fs');
|
|
65
|
-
var client = new Client({
|
|
66
|
-
node: protocol + '://' + auth + '@' + host + ':' + port,
|
|
67
|
-
ssl: {
|
|
68
|
-
ca: fs.readFileSync(ca_certs_path),
|
|
69
|
-
// You can turn off certificate verification (rejectUnauthorized: false) if you're using self-signed certificates with a hostname mismatch.
|
|
70
|
-
// cert: fs.readFileSync(client_cert_path),
|
|
71
|
-
// key: fs.readFileSync(client_key_path)
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
async function search() {
|
|
76
|
-
// Create an index with non-default settings.
|
|
77
|
-
var index_name = 'books';
|
|
78
|
-
var settings = {
|
|
79
|
-
settings: {
|
|
80
|
-
index: {
|
|
81
|
-
number_of_shards: 4,
|
|
82
|
-
number_of_replicas: 3,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
var response = await client.indices.create({
|
|
88
|
-
index: index_name,
|
|
89
|
-
body: settings,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
console.log('Creating index:');
|
|
93
|
-
console.log(response.body);
|
|
94
|
-
|
|
95
|
-
// Add a document to the index.
|
|
96
|
-
var document = {
|
|
97
|
-
title: 'The Outsider',
|
|
98
|
-
author: 'Stephen King',
|
|
99
|
-
year: '2018',
|
|
100
|
-
genre: 'Crime fiction',
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var id = '1';
|
|
104
|
-
|
|
105
|
-
var response = await client.index({
|
|
106
|
-
id: id,
|
|
107
|
-
index: index_name,
|
|
108
|
-
body: document,
|
|
109
|
-
refresh: true,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
console.log('Adding document:');
|
|
113
|
-
console.log(response.body);
|
|
114
|
-
|
|
115
|
-
// Search for the document.
|
|
116
|
-
var query = {
|
|
117
|
-
query: {
|
|
118
|
-
match: {
|
|
119
|
-
title: {
|
|
120
|
-
query: 'The Outsider',
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
var response = await client.search({
|
|
127
|
-
index: index_name,
|
|
128
|
-
body: query,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
console.log('Search results:');
|
|
132
|
-
console.log(response.body.hits);
|
|
133
|
-
|
|
134
|
-
// Delete the document.
|
|
135
|
-
var response = await client.delete({
|
|
136
|
-
index: index_name,
|
|
137
|
-
id: id,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
console.log('Deleting document:');
|
|
141
|
-
console.log(response.body);
|
|
142
|
-
|
|
143
|
-
// Delete the index.
|
|
144
|
-
var response = await client.indices.delete({
|
|
145
|
-
index: index_name,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
console.log('Deleting index:');
|
|
149
|
-
console.log(response.body);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
search().catch(console.log);
|
|
153
|
-
```
|
|
154
51
|
|
|
155
52
|
## Project Resources
|
|
156
53
|
|
package/RELEASING.md
CHANGED
|
@@ -31,4 +31,10 @@ 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 a draft release will be created.
|
|
38
|
+
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).
|
|
39
|
+
1. Once the above release workflow is successful, the drafted release on GitHub is published automatically.
|
|
40
|
+
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
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# User Guide
|
|
2
|
+
|
|
3
|
+
- [User Guide](#user-guide)
|
|
4
|
+
- [Initializing a Client](#initializing-a-client)
|
|
5
|
+
- [Authenticate with Amazon OpenSearch Service](#authenticate-with-amazon-opensearch-service)
|
|
6
|
+
- [Using AWS V2 SDK](#using-aws-v2-sdk)
|
|
7
|
+
- [Using AWS V3 SDK](#using-aws-v3-sdk)
|
|
8
|
+
- [Create an Index](#create-an-index)
|
|
9
|
+
- [Add a Document to the Index](#add-a-document-to-the-index)
|
|
10
|
+
- [Search for the Document](#search-for-the-document)
|
|
11
|
+
- [Delete the document](#delete-the-document)
|
|
12
|
+
- [Delete the index](#delete-the-index)
|
|
13
|
+
|
|
14
|
+
## Initializing a Client
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
'use strict';
|
|
18
|
+
|
|
19
|
+
var host = 'localhost';
|
|
20
|
+
var protocol = 'https';
|
|
21
|
+
var port = 9200;
|
|
22
|
+
var auth = 'admin:admin'; // For testing only. Don't store credentials in code.
|
|
23
|
+
var ca_certs_path = '/full/path/to/root-ca.pem';
|
|
24
|
+
|
|
25
|
+
// Optional client certificates if you don't want to use HTTP basic authentication.
|
|
26
|
+
// var client_cert_path = '/full/path/to/client.pem'
|
|
27
|
+
// var client_key_path = '/full/path/to/client-key.pem'
|
|
28
|
+
|
|
29
|
+
// Create a client with SSL/TLS enabled.
|
|
30
|
+
var { Client } = require('@opensearch-project/opensearch');
|
|
31
|
+
var fs = require('fs');
|
|
32
|
+
var client = new Client({
|
|
33
|
+
node: protocol + '://' + auth + '@' + host + ':' + port,
|
|
34
|
+
ssl: {
|
|
35
|
+
ca: fs.readFileSync(ca_certs_path),
|
|
36
|
+
// You can turn off certificate verification (rejectUnauthorized: false) if you're using self-signed certificates with a hostname mismatch.
|
|
37
|
+
// cert: fs.readFileSync(client_cert_path),
|
|
38
|
+
// key: fs.readFileSync(client_key_path)
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Authenticate with Amazon OpenSearch Service
|
|
44
|
+
|
|
45
|
+
#### Using AWS V2 SDK
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
const AWS = require('aws-sdk'); // V2 SDK.
|
|
49
|
+
const { Client } = require('@opensearch-project/opensearch');
|
|
50
|
+
const { AwsSigv4Signer } = require('@opensearch-project/opensearch/aws');
|
|
51
|
+
|
|
52
|
+
const client = new Client({
|
|
53
|
+
...AwsSigv4Signer({
|
|
54
|
+
region: 'us-east-1',
|
|
55
|
+
// Must return a Promise that resolve to an AWS.Credentials object.
|
|
56
|
+
// This function is used to acquire the credentials when the client start and
|
|
57
|
+
// when the credentials are expired.
|
|
58
|
+
// The Client will refresh the Credentials only when they are expired.
|
|
59
|
+
// With AWS SDK V2, Credentials.refreshPromise is used when available to refresh the credentials.
|
|
60
|
+
|
|
61
|
+
// Example with AWS SDK V2:
|
|
62
|
+
getCredentials: () =>
|
|
63
|
+
new Promise((resolve, reject) => {
|
|
64
|
+
// Any other method to acquire a new Credentials object can be used.
|
|
65
|
+
AWS.config.getCredentials((err, credentials) => {
|
|
66
|
+
if (err) {
|
|
67
|
+
reject(err);
|
|
68
|
+
} else {
|
|
69
|
+
resolve(credentials);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}),
|
|
73
|
+
}),
|
|
74
|
+
node: 'https://search-xxx.region.es.amazonaws.com', // OpenSearch domain URL
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### Using AWS V3 SDK
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
const { defaultProvider } = require('@aws-sdk/credential-provider-node'); // V3 SDK.
|
|
82
|
+
const { Client } = require('@opensearch-project/opensearch');
|
|
83
|
+
const { AwsSigv4Signer } = require('@opensearch-project/opensearch/aws');
|
|
84
|
+
|
|
85
|
+
const client = new Client({
|
|
86
|
+
...AwsSigv4Signer({
|
|
87
|
+
region: 'us-east-1',
|
|
88
|
+
// Must return a Promise that resolve to an AWS.Credentials object.
|
|
89
|
+
// This function is used to acquire the credentials when the client start and
|
|
90
|
+
// when the credentials are expired.
|
|
91
|
+
// The Client will refresh the Credentials only when they are expired.
|
|
92
|
+
// With AWS SDK V2, Credentials.refreshPromise is used when available to refresh the credentials.
|
|
93
|
+
|
|
94
|
+
// Example with AWS SDK V3:
|
|
95
|
+
getCredentials: () => {
|
|
96
|
+
// Any other method to acquire a new Credentials object can be used.
|
|
97
|
+
const credentialsProvider = defaultProvider();
|
|
98
|
+
return credentialsProvider();
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
node: 'https://search-xxx.region.es.amazonaws.com', // OpenSearch domain URL
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Create an Index
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
console.log('Creating index:');
|
|
109
|
+
|
|
110
|
+
var index_name = 'books';
|
|
111
|
+
var settings = {
|
|
112
|
+
settings: {
|
|
113
|
+
index: {
|
|
114
|
+
number_of_shards: 4,
|
|
115
|
+
number_of_replicas: 3,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var response = await client.indices.create({
|
|
121
|
+
index: index_name,
|
|
122
|
+
body: settings,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
console.log(response.body);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Add a Document to the Index
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
console.log('Adding document:');
|
|
132
|
+
|
|
133
|
+
var document = {
|
|
134
|
+
title: 'The Outsider',
|
|
135
|
+
author: 'Stephen King',
|
|
136
|
+
year: '2018',
|
|
137
|
+
genre: 'Crime fiction',
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
var id = '1';
|
|
141
|
+
|
|
142
|
+
var response = await client.index({
|
|
143
|
+
id: id,
|
|
144
|
+
index: index_name,
|
|
145
|
+
body: document,
|
|
146
|
+
refresh: true,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
console.log(response.body);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Search for the Document
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
console.log('Search results:');
|
|
156
|
+
|
|
157
|
+
var query = {
|
|
158
|
+
query: {
|
|
159
|
+
match: {
|
|
160
|
+
title: {
|
|
161
|
+
query: 'The Outsider',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
var response = await client.search({
|
|
168
|
+
index: index_name,
|
|
169
|
+
body: query,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
console.log(response.body.hits);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Delete the document
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
console.log('Deleting document:');
|
|
179
|
+
|
|
180
|
+
var response = await client.delete({
|
|
181
|
+
index: index_name,
|
|
182
|
+
id: id,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
console.log(response.body);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Delete the index
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
console.log('Deleting index:');
|
|
192
|
+
|
|
193
|
+
var response = await client.indices.delete({
|
|
194
|
+
index: index_name,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
console.log(response.body);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Create a Point in Time
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
console.log('Creating a PIT:');
|
|
204
|
+
|
|
205
|
+
var response = await client.createPit({
|
|
206
|
+
index: 'books*',
|
|
207
|
+
keep_alive: '100m',
|
|
208
|
+
expand_wildcards: 'all',
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
console.log(response.body);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Get all PITs
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
console.log('Getting all PITs:');
|
|
218
|
+
|
|
219
|
+
var response = await client.getAllPits();
|
|
220
|
+
|
|
221
|
+
console.log(response.body);
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Delete a Point in Time
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
console.log('Deleting a PIT:');
|
|
228
|
+
|
|
229
|
+
var response = await client.deletePit({
|
|
230
|
+
body: {
|
|
231
|
+
pit_id: [
|
|
232
|
+
'o463QQEPbXktaW5kZXgtMDAwMDAxFkhGN09fMVlPUkVPLXh6MUExZ1hpaEEAFjBGbmVEZHdGU1EtaFhhUFc4ZkR5cWcAAAAAAAAAAAEWaXBPNVJtZEhTZDZXTWFFR05waXdWZwEWSEY3T18xWU9SRU8teHoxQTFnWGloQQAA',
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
console.log(response.body);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Delete all PITs
|
|
241
|
+
|
|
242
|
+
```javascript
|
|
243
|
+
console.log('Deleting all PITs:');
|
|
244
|
+
|
|
245
|
+
var response = await client.deleteAllPits();
|
|
246
|
+
|
|
247
|
+
console.log(response.body);
|
|
248
|
+
```
|