@opensearch-project/opensearch 1.1.0 → 2.0.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.
Files changed (86) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +26 -0
  3. package/.prettierrc.json +5 -0
  4. package/.whitesource +15 -0
  5. package/ADMINS.md +18 -11
  6. package/COMPATIBILITY.md +24 -0
  7. package/DEVELOPER_GUIDE.md +22 -5
  8. package/MAINTAINERS.md +23 -18
  9. package/README.md +100 -101
  10. package/RELEASING.md +3 -3
  11. package/SECURITY.md +1 -1
  12. package/api/api/bulk.js +53 -26
  13. package/api/api/cat.js +354 -264
  14. package/api/api/clear_scroll.js +17 -17
  15. package/api/api/cluster.js +366 -219
  16. package/api/api/count.js +55 -24
  17. package/api/api/create.js +50 -24
  18. package/api/api/dangling_indices.js +95 -51
  19. package/api/api/delete.js +49 -22
  20. package/api/api/delete_by_query.js +88 -25
  21. package/api/api/delete_by_query_rethrottle.js +33 -19
  22. package/api/api/delete_script.js +31 -17
  23. package/api/api/exists.js +55 -22
  24. package/api/api/exists_source.js +60 -27
  25. package/api/api/explain.js +60 -22
  26. package/api/api/features.js +56 -35
  27. package/api/api/field_caps.js +36 -18
  28. package/api/api/get.js +55 -22
  29. package/api/api/get_script.js +30 -17
  30. package/api/api/get_script_context.js +15 -15
  31. package/api/api/get_script_languages.js +15 -15
  32. package/api/api/get_source.js +55 -22
  33. package/api/api/index.js +60 -28
  34. package/api/api/indices.js +1068 -857
  35. package/api/api/info.js +15 -15
  36. package/api/api/ingest.js +132 -96
  37. package/api/api/mget.js +50 -26
  38. package/api/api/msearch.js +49 -26
  39. package/api/api/msearch_template.js +53 -26
  40. package/api/api/mtermvectors.js +48 -24
  41. package/api/api/nodes.js +281 -154
  42. package/api/api/ping.js +15 -15
  43. package/api/api/put_script.js +40 -25
  44. package/api/api/rank_eval.js +37 -20
  45. package/api/api/reindex.js +38 -17
  46. package/api/api/reindex_rethrottle.js +32 -19
  47. package/api/api/render_search_template.js +18 -18
  48. package/api/api/scripts_painless_execute.js +15 -15
  49. package/api/api/scroll.js +31 -17
  50. package/api/api/search.js +108 -24
  51. package/api/api/search_shards.js +36 -18
  52. package/api/api/search_template.js +64 -26
  53. package/api/api/shutdown.js +66 -54
  54. package/api/api/snapshot.js +347 -224
  55. package/api/api/tasks.js +65 -46
  56. package/api/api/terms_enum.js +17 -17
  57. package/api/api/termvectors.js +57 -26
  58. package/api/api/update.js +64 -24
  59. package/api/api/update_by_query.js +89 -23
  60. package/api/api/update_by_query_rethrottle.js +33 -19
  61. package/api/index.js +267 -179
  62. package/api/new.d.ts +2042 -529
  63. package/api/opensearch_dashboards.d.ts +239 -236
  64. package/api/requestParams.d.ts +301 -69
  65. package/api/types.d.ts +6204 -5719
  66. package/api/utils.js +22 -22
  67. package/codecov.yml +2 -2
  68. package/index.d.ts +4776 -935
  69. package/index.js +152 -140
  70. package/index.mjs +9 -9
  71. package/lib/Connection.d.ts +37 -26
  72. package/lib/Connection.js +163 -168
  73. package/lib/Helpers.d.ts +103 -64
  74. package/lib/Helpers.js +398 -371
  75. package/lib/Serializer.d.ts +2 -2
  76. package/lib/Serializer.js +39 -39
  77. package/lib/Transport.d.ts +30 -12
  78. package/lib/Transport.js +375 -336
  79. package/lib/errors.d.ts +25 -7
  80. package/lib/errors.js +75 -71
  81. package/lib/pool/BaseConnectionPool.js +100 -97
  82. package/lib/pool/CloudConnectionPool.js +16 -16
  83. package/lib/pool/ConnectionPool.js +105 -105
  84. package/lib/pool/index.d.ts +8 -6
  85. package/lib/pool/index.js +6 -6
  86. package/package.json +13 -8
package/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ coverage
package/.eslintrc.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "env": {
3
+ "node": true,
4
+ "es6": true
5
+ },
6
+ "extends": [
7
+ "eslint:recommended",
8
+ "prettier"
9
+ ],
10
+ "parser": "babel-eslint",
11
+ "plugins": [
12
+ "prettier"
13
+ ],
14
+ "rules": {
15
+ "prettier/prettier": [
16
+ "error",
17
+ {
18
+ "endOfLine": "auto"
19
+ }
20
+ ],
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
+ /*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
+ }
26
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "es5",
4
+ "printWidth": 100
5
+ }
package/.whitesource ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "scanSettings": {
3
+ "configMode": "AUTO",
4
+ "configExternalURL": "",
5
+ "projectToken": "",
6
+ "baseBranches": []
7
+ },
8
+ "checkRunSettings": {
9
+ "vulnerableCheckRunConclusionLevel": "failure",
10
+ "displayMode": "diff"
11
+ },
12
+ "issueSettings": {
13
+ "minSeverityLevel": "LOW"
14
+ }
15
+ }
package/ADMINS.md CHANGED
@@ -1,19 +1,26 @@
1
+ - [Overview](#overview)
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
+
1
8
  ## Overview
2
9
 
3
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).
4
11
 
5
12
  ## Current Admins
6
13
 
7
- | Admin | GitHub ID | Affiliation |
8
- | -------------------------| --------------------------------------- | ----------- |
9
- | Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
10
- | Bishoy Boktor | [boktorbb-amzn](https://github.com/boktorbb-amzn) | Amazon |
11
- | Charlotte | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
12
- | Henri Yandell | [hyandell](https://github.com/hyandell) | Amazon |
13
- | Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
14
- | Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
15
- | Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
16
- | Tommy Markley | [tmarkley](https://github.com/tmarkley) | Amazon |
14
+ | Admin | GitHub ID | Affiliation |
15
+ | --------------------- | ------------------------------------------------- | ----------- |
16
+ | Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
17
+ | Bishoy Boktor | [boktorbb-amzn](https://github.com/boktorbb-amzn) | Amazon |
18
+ | Charlotte | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
19
+ | Henri Yandell | [hyandell](https://github.com/hyandell) | Amazon |
20
+ | Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
21
+ | Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
22
+ | Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
23
+ | Tommy Markley | [tmarkley](https://github.com/tmarkley) | Amazon |
17
24
 
18
25
  ## Admin Responsibilities
19
26
 
@@ -31,4 +38,4 @@ Act on [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) violations by revoking access, and
31
38
 
32
39
  ### Adopt Organizational Best Practices
33
40
 
34
- 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.
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.
@@ -0,0 +1,24 @@
1
+ - [Compatibility with OpenSearch](#compatibility-with-opensearch)
2
+ - [Upgrading](#upgrading)
3
+
4
+ ## Compatibility with OpenSearch
5
+
6
+ The below matrix shows the compatibility of the [`opensearch-js`](https://www.npmjs.com/package/@opensearch-project/opensearch) with versions of [`OpenSearch`](https://opensearch.org/downloads.html#opensearch).
7
+
8
+ | OpenSearch Version | Client Version |
9
+ | ------------------ | -------------- |
10
+ | 1.0.0 | 1.0.0 |
11
+ | 1.0.1 | 1.0.0 |
12
+ | 1.1.0 | 1.1.0 |
13
+ | 1.2.0 | 1.1.0 |
14
+ | 1.2.1 | 1.1.0 |
15
+ | 1.2.2 | 1.1.0 |
16
+ | 1.2.3 | 1.1.0 |
17
+ | 1.2.4 | 1.1.0 |
18
+ | 1.3.0 | 1.1.0 |
19
+ | 1.3.1 | 1.1.0 |
20
+ | 2.0.0 | 2.0.0 |
21
+
22
+ ## Upgrading
23
+
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.3.1, 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.
@@ -1,6 +1,16 @@
1
+ - [Developer Guide](#developer-guide)
2
+ - [Getting Started](#getting-started)
3
+ - [Git Clone OpenSearch Node.js Client Repository](#git-clone-opensearch-nodejs-client-repository)
4
+ - [Install Prerequisites](#install-prerequisites)
5
+ - [Node.js](#nodejs)
6
+ - [Docker](#docker)
7
+ - [Unit Testing](#unit-testing)
8
+ - [Integration Testing](#integration-testing)
9
+ - [Execute integration tests from your terminal](#execute-integration-tests-from-your-terminal)
10
+
1
11
  # Developer Guide
2
12
 
3
- So you want to contribute code to the OpenSearch Node.js Client? Excellent! We're glad you're here. Here's what you need to do:
13
+ So you want to contribute code to the OpenSearch Node.js Client? Excellent! We're glad you're here. Here's what you need to do:
4
14
 
5
15
  ## Getting Started
6
16
 
@@ -11,7 +21,8 @@ e.g. `git clone https://github.com/[your username]/opensearch-js.git`.
11
21
 
12
22
  ### Install Prerequisites
13
23
 
14
- #### Node.js
24
+ #### Node.js
25
+
15
26
  The minimum supported version of Node.js is v10.
16
27
 
17
28
  #### Docker
@@ -19,32 +30,38 @@ The minimum supported version of Node.js is v10.
19
30
  [Docker](https://docs.docker.com/install/) is required for building some OpenSearch artifacts and executing integration tests.
20
31
 
21
32
  ### Unit Testing
33
+
22
34
  Go to your terminal and run:
35
+
23
36
  ```
24
37
  cd folder-path
25
38
  npm run test:unit
26
39
  ```
27
-
40
+
28
41
  To run a specific unit test, you can use the following jest command. `npm test` will not work.
42
+
29
43
  ```
30
44
  cd folder-path/to/test
31
45
  jest TestName
32
46
  ```
33
47
 
34
48
  If you don't have jest, you can install it via npm or yarn
49
+
35
50
  ```
36
51
  npm i -g jest-cli
37
52
  yarn global add jest-cli
38
53
  ```
39
54
 
40
55
  ### Integration Testing
41
- In order to test opensearch-js client, you need a running OpenSearch cluster. You can use Docker to accomplish this.
56
+
57
+ In order to test opensearch-js client, you need a running OpenSearch cluster. You can use Docker to accomplish this.
42
58
  The [Docker Compose file](.ci/opensearch/docker-compose.yml) supports the ability to run integration tests for the project in local environments.
43
59
  If you have not installed docker-compose, you can install it from this [link](https://docs.docker.com/compose/install/).
44
60
 
45
61
  #### Execute integration tests from your terminal
46
62
 
47
63
  1. Run below command to start containers. By default, it will launch latest OpenSearch cluster.
64
+
48
65
  ```
49
66
  cd folder-path/.ci/opensearch
50
67
  docker-compose up
@@ -54,7 +71,7 @@ If you have not installed docker-compose, you can install it from this [link](ht
54
71
  ```
55
72
  npm run test:integration:helpers
56
73
  ```
57
- 5. Stop and clean containers.
74
+ 3. Stop and clean containers.
58
75
  ```
59
76
  docker-compose down
60
77
  ```
package/MAINTAINERS.md CHANGED
@@ -1,15 +1,16 @@
1
1
  - [Overview](#overview)
2
2
  - [Current Maintainers](#current-maintainers)
3
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
- - [Be Responsive](#be-responsive)
9
- - [Maintain Overall Health of the Repo](#maintain-overall-health-of-the-repo)
10
- - [Use Semver](#use-semver)
11
- - [Release Frequently](#release-frequently)
12
- - [Promote Other Maintainers](#promote-other-maintainers)
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)
13
14
 
14
15
  ## Overview
15
16
 
@@ -17,14 +18,14 @@ This document explains who the maintainers are (see below), what they do in this
17
18
 
18
19
  ## Current Maintainers
19
20
 
20
- | Maintainer | GitHub ID | Affiliation |
21
- | ------------------------ | --------------------------------------- | ----------- |
22
- | Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
23
- | Bishoy Boktor | [boktorbb-amzn](https://github.com/boktorbb-amzn) | Amazon |
24
- | Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
25
- | Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
26
- | Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
27
- | Tommy Markley | [tmarkley](https://github.com/tmarkley) | Amazon |
21
+ | Maintainer | GitHub ID | Affiliation |
22
+ | --------------------- | ------------------------------------------------- | ----------- |
23
+ | Anan Zhuang | [ananzh](https://github.com/ananzh) | Amazon |
24
+ | Bishoy Boktor | [boktorbb-amzn](https://github.com/boktorbb-amzn) | Amazon |
25
+ | Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
26
+ | Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
27
+ | Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
28
+ | Tommy Markley | [tmarkley](https://github.com/tmarkley) | Amazon |
28
29
 
29
30
  ## Maintainer Responsibilities
30
31
 
@@ -52,6 +53,10 @@ All repositories in this organization have a standard set of labels, including `
52
53
 
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.
54
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
+
55
60
  ### Be Responsive
56
61
 
57
62
  Respond to enhancement requests, and forum posts. Allocate time to reviewing and commenting on issues and conversations as they come in.
@@ -70,4 +75,4 @@ Make frequent project releases to the community.
70
75
 
71
76
  ### Promote Other Maintainers
72
77
 
73
- Assist, add, and remove [MAINTAINERS](MAINTAINERS.md). Exercise good judgement, and propose high quality contributors to become co-maintainers.
78
+ Assist, add, and remove [MAINTAINERS](MAINTAINERS.md). Exercise good judgement, and propose high quality contributors to become co-maintainers.
package/README.md CHANGED
@@ -10,6 +10,9 @@
10
10
  OpenSearch Node.js client
11
11
 
12
12
  - [Welcome!](#welcome)
13
+ - [Example use](#example-use)
14
+ - [Setup](#setup)
15
+ - [Sample code](#sample-code)
13
16
  - [Project Resources](#project-resources)
14
17
  - [Code of Conduct](#code-of-conduct)
15
18
  - [License](#license)
@@ -20,14 +23,14 @@ OpenSearch Node.js client
20
23
  **[opensearch-js](https://www.npmjs.com/package/@opensearch-project/opensearch)** is [a community-driven, open source fork](https://aws.amazon.com/blogs/opensource/introducing-opensearch/) of elasticsearch-js licensed under the [Apache v2.0 License](LICENSE.txt). For more information, see [opensearch.org](https://opensearch.org/).
21
24
 
22
25
  ## Example use
26
+
23
27
  The OpenSearch JavaScript client provides a safer and easier way to interact with your OpenSearch cluster. Rather than using OpenSearch from the browser and potentially exposing your data to the public, you can build an OpenSearch client that takes care of sending requests to your cluster.
24
28
 
25
29
  The client contains a library of APIs that let you perform different operations on your cluster and return a standard response body. The example here demonstrates some basic operations like creating an index, adding documents, and searching your data.
26
30
 
27
-
28
31
  ### Setup
29
32
 
30
- # To add the client to your project, install it with npm:
33
+ To add the client to your project, install it with npm:
31
34
 
32
35
  ```bash
33
36
  npm i @opensearch-project/opensearch
@@ -38,10 +41,9 @@ If you prefer to add the client manually or just want to examine the source code
38
41
  Then require the client:
39
42
 
40
43
  ```javascript
41
- const { Client } = require('@opensearch-project/opensearch')
44
+ const { Client } = require('@opensearch-project/opensearch');
42
45
  ```
43
46
 
44
-
45
47
  ### Sample code
46
48
 
47
49
  ```javascript
@@ -61,116 +63,113 @@ var ca_certs_path = '/full/path/to/root-ca.pem';
61
63
  var { Client } = require('@opensearch-project/opensearch');
62
64
  var fs = require('fs');
63
65
  var client = new Client({
64
- node: protocol + '://' + auth + '@' + host + ':' + port,
65
- ssl: {
66
- ca: fs.readFileSync(ca_certs_path),
67
- // You can turn off certificate verification (rejectUnauthorized: false) if you're using self-signed certificates with a hostname mismatch.
68
- // cert: fs.readFileSync(client_cert_path),
69
- // key: fs.readFileSync(client_key_path)
70
- }
71
- })
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
+ });
72
74
 
73
75
  async function search() {
74
-
75
- // Create an index with non-default settings.
76
- var index_name = 'books'
77
- var settings = {
78
- 'settings': {
79
- 'index': {
80
- 'number_of_shards': 4,
81
- 'number_of_replicas': 3
82
- }
83
- }
84
- }
85
-
86
- var response = await client.indices.create({
87
- index: index_name,
88
- body: settings
89
- })
90
-
91
- console.log('Creating index:')
92
- console.log(response.body)
93
-
94
- // Add a document to the index.
95
- var document = {
96
- 'title': 'The Outsider',
97
- 'author': 'Stephen King',
98
- 'year': '2018',
99
- 'genre': 'Crime fiction'
100
- }
101
-
102
- var id = '1'
103
-
104
- var response = await client.index({
105
- id: id,
106
- index: index_name,
107
- body: document,
108
- refresh: true
109
- })
110
-
111
- console.log('Adding document:')
112
- console.log(response.body)
113
-
114
- // Search for the document.
115
- var query = {
116
- 'query': {
117
- 'match': {
118
- 'title': {
119
- 'query': 'The Outsider'
120
- }
121
- }
122
- }
123
- }
124
-
125
- var response = await client.search({
126
- index: index_name,
127
- body: query
128
- })
129
-
130
- console.log('Search results:')
131
- console.log(response.body.hits)
132
-
133
- // Delete the document.
134
- var response = await client.delete({
135
- index: index_name,
136
- id: id
137
- })
138
-
139
- console.log('Deleting document:')
140
- console.log(response.body)
141
-
142
- // Delete the index.
143
- var response = await client.indices.delete({
144
- index: index_name
145
- })
146
-
147
- console.log('Deleting index:')
148
- console.log(response.body)
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);
149
150
  }
150
151
 
151
- search().catch(console.log)
152
+ search().catch(console.log);
152
153
  ```
153
154
 
154
155
  ## Project Resources
155
156
 
156
- * [Project Website](https://opensearch.org/)
157
- * [Downloads](https://opensearch.org/downloads.html).
158
- * [Documentation](https://opensearch.org/docs/)
159
- * Need help? Try [Forums](https://discuss.opendistrocommunity.dev/)
160
- * [Project Principles](https://opensearch.org/#principles)
161
- * [Contributing to OpenSearch](CONTRIBUTING.md)
162
- * [Maintainer Responsibilities](MAINTAINERS.md)
163
- * [Release Management](RELEASING.md)
164
- * [Admin Responsibilities](ADMINS.md)
165
- * [Security](SECURITY.md)
166
- * [NPM Page](https://www.npmjs.com/package/@opensearch-project/opensearch)
167
-
157
+ - [Project Website](https://opensearch.org/)
158
+ - [Downloads](https://opensearch.org/downloads.html).
159
+ - [Documentation](https://opensearch.org/docs/)
160
+ - Need help? Try [Forums](https://discuss.opendistrocommunity.dev/)
161
+ - [Project Principles](https://opensearch.org/#principles)
162
+ - [Contributing to OpenSearch](CONTRIBUTING.md)
163
+ - [Maintainer Responsibilities](MAINTAINERS.md)
164
+ - [Release Management](RELEASING.md)
165
+ - [Admin Responsibilities](ADMINS.md)
166
+ - [Security](SECURITY.md)
167
+ - [NPM Page](https://www.npmjs.com/package/@opensearch-project/opensearch)
168
168
 
169
169
  ## Code of Conduct
170
170
 
171
171
  This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUCT.md). For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq), or contact [opensource-codeofconduct@amazon.com](mailto:opensource-codeofconduct@amazon.com) with any additional questions or comments.
172
172
 
173
-
174
173
  ## License
175
174
 
176
175
  This project is licensed under the [Apache v2.0 License](LICENSE.txt).
package/RELEASING.md CHANGED
@@ -15,9 +15,9 @@ This document explains the release strategy for artifacts in this organization.
15
15
 
16
16
  Given the current major release of 1.0, projects in this organization maintain the following active branches.
17
17
 
18
- * **main**: The next _major_ release. This is the branch where all merges take place and code moves fast.
19
- * **1.x**: The next _minor_ release. Once a change is merged into `main`, decide whether to backport it to `1.x`.
20
- * **1.0**: The _current_ release. In between minor releases, only hotfixes (e.g. security) are backported to `1.0`.
18
+ - **main**: The next _major_ release. This is the branch where all merges take place and code moves fast.
19
+ - **1.x**: The next _minor_ release. Once a change is merged into `main`, decide whether to backport it to `1.x`.
20
+ - **1.0**: The _current_ release. In between minor releases, only hotfixes (e.g. security) are backported to `1.0`.
21
21
 
22
22
  Label PRs with the next major version label (e.g. `2.0.0`) and merge changes into `main`. Label PRs that you believe need to be backported as `1.x` and `1.0`. Backport PRs by checking out the versioned branch, cherry-pick changes and open a PR against each target backport branch.
23
23
 
package/SECURITY.md CHANGED
@@ -1,3 +1,3 @@
1
1
  ## Reporting a Vulnerability
2
2
 
3
- If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. Please do **not** create a public GitHub issue.
3
+ If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. Please do **not** create a public GitHub issue.
package/api/api/bulk.js CHANGED
@@ -28,43 +28,70 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
35
 
36
- const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
- const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'type', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
- const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'wait_for_active_shards',
39
+ 'refresh',
40
+ 'routing',
41
+ 'timeout',
42
+ 'type',
43
+ '_source',
44
+ '_source_excludes',
45
+ '_source_exclude',
46
+ '_source_includes',
47
+ '_source_include',
48
+ 'pipeline',
49
+ 'require_alias',
50
+ 'pretty',
51
+ 'human',
52
+ 'error_trace',
53
+ 'source',
54
+ 'filter_path',
55
+ ];
56
+ const snakeCase = {
57
+ waitForActiveShards: 'wait_for_active_shards',
58
+ _sourceExcludes: '_source_excludes',
59
+ _sourceExclude: '_source_exclude',
60
+ _sourceIncludes: '_source_includes',
61
+ _sourceInclude: '_source_include',
62
+ requireAlias: 'require_alias',
63
+ errorTrace: 'error_trace',
64
+ filterPath: 'filter_path',
65
+ };
39
66
 
40
- function bulkApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
67
+ function bulkApi(params, options, callback) {
68
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
69
 
43
70
  // check required parameters
44
71
  if (params.body == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: body')
46
- return handleError(err, callback)
72
+ const err = new this[kConfigurationError]('Missing required parameter: body');
73
+ return handleError(err, callback);
47
74
  }
48
75
 
49
76
  // check required url components
50
- if (params.type != null && (params.index == null)) {
51
- const err = new this[kConfigurationError]('Missing required parameter of the url: index')
52
- return handleError(err, callback)
77
+ if (params.type != null && params.index == null) {
78
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index');
79
+ return handleError(err, callback);
53
80
  }
54
81
 
55
- let { method, body, index, type, ...querystring } = params
56
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
82
+ let { method, body, index, type, ...querystring } = params;
83
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
57
84
 
58
- let path = ''
59
- if ((index) != null && (type) != null) {
60
- if (method == null) method = 'POST'
61
- path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk'
62
- } else if ((index) != null) {
63
- if (method == null) method = 'POST'
64
- path = '/' + encodeURIComponent(index) + '/' + '_bulk'
85
+ let path = '';
86
+ if (index != null && type != null) {
87
+ if (method == null) method = 'POST';
88
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk';
89
+ } else if (index != null) {
90
+ if (method == null) method = 'POST';
91
+ path = '/' + encodeURIComponent(index) + '/' + '_bulk';
65
92
  } else {
66
- if (method == null) method = 'POST'
67
- path = '/' + '_bulk'
93
+ if (method == null) method = 'POST';
94
+ path = '/' + '_bulk';
68
95
  }
69
96
 
70
97
  // build request object
@@ -72,10 +99,10 @@ function bulkApi (params, options, callback) {
72
99
  method,
73
100
  path,
74
101
  bulkBody: body,
75
- querystring
76
- }
102
+ querystring,
103
+ };
77
104
 
78
- return this.transport.request(request, options, callback)
105
+ return this.transport.request(request, options, callback);
79
106
  }
80
107
 
81
- module.exports = bulkApi
108
+ module.exports = bulkApi;