@opensearch-project/opensearch 3.0.0-beta.4 → 3.0.0-beta.6

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 (54) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/api/cat/_api.js +24 -26
  3. package/api/cluster/_api.js +21 -23
  4. package/api/danglingIndices/_api.js +3 -5
  5. package/api/http/_api.js +9 -11
  6. package/api/indices/_api.js +48 -50
  7. package/api/ingest/_api.js +5 -7
  8. package/api/knn/_api.js +6 -8
  9. package/api/ml/_api.js +7 -9
  10. package/api/nodes/_api.js +5 -7
  11. package/api/notifications/_api.js +9 -11
  12. package/api/ppl/_api.js +4 -6
  13. package/api/remoteStore/_api.js +1 -3
  14. package/api/rollups/_api.js +6 -8
  15. package/api/searchPipeline/_api.js +3 -5
  16. package/api/security/_api.js +74 -76
  17. package/api/snapshot/_api.js +11 -13
  18. package/api/sql/_api.js +6 -8
  19. package/api/tasks/_api.js +3 -5
  20. package/api/transforms/_api.js +8 -10
  21. package/api/utils.js +6 -7
  22. package/lib/OpenSearchAPI.d.ts +1403 -0
  23. package/lib/OpenSearchAPI.js +117 -0
  24. package/package.json +5 -1
  25. package/.dockerignore +0 -5
  26. package/.eslintignore +0 -2
  27. package/.eslintrc.json +0 -34
  28. package/.prettierrc.json +0 -5
  29. package/.whitesource +0 -15
  30. package/ADMINS.md +0 -16
  31. package/COMPATIBILITY.md +0 -13
  32. package/DEVELOPER_GUIDE.md +0 -127
  33. package/MAINTAINERS.md +0 -23
  34. package/Makefile +0 -17
  35. package/RELEASING.md +0 -41
  36. package/SECURITY.md +0 -3
  37. package/USER_GUIDE.md +0 -316
  38. package/codecov.yml +0 -14
  39. package/guides/advanced_index_actions.md +0 -92
  40. package/guides/bulk.md +0 -126
  41. package/guides/document_lifecycle.md +0 -162
  42. package/guides/index_lifecycle.md +0 -142
  43. package/guides/index_template.md +0 -228
  44. package/guides/json.md +0 -53
  45. package/guides/msearch.md +0 -56
  46. package/guides/search.md +0 -203
  47. package/jenkins/release.JenkinsFile +0 -11
  48. package/samples/README.md +0 -17
  49. package/samples/bulk.js +0 -91
  50. package/samples/json.js +0 -75
  51. package/samples/msearch.js +0 -131
  52. package/samples/rollups.js +0 -139
  53. package/samples/search.js +0 -155
  54. package/samples/transforms.ts +0 -146
package/samples/search.js DELETED
@@ -1,155 +0,0 @@
1
- /*
2
- * Copyright OpenSearch Contributors
3
- * SPDX-License-Identifier: Apache-2.0
4
- *
5
- * The OpenSearch Contributors require contributions made to
6
- * this file be licensed under the Apache-2.0 license or a
7
- * compatible open source license.
8
- *
9
- */
10
- const { Client } = require('@opensearch-project/opensearch');
11
-
12
- // Instantiate a client with basic auth as setup in the README.md file
13
- const client = new Client({
14
- ssl: {
15
- rejectUnauthorized: false,
16
- },
17
- node: 'https://localhost:9200',
18
- auth: {
19
- username: 'admin',
20
- password: 'myStrongPassword123!',
21
- },
22
- });
23
-
24
- const printResponse = (title, response) => {
25
- console.log(`\n${title}:`);
26
- console.log(response.body);
27
- };
28
-
29
- const refreshIndex = async (indexName) => {
30
- try {
31
- const response = await client.indices.refresh({
32
- index: indexName,
33
- });
34
-
35
- printResponse(`Refresh response for index ${indexName}`, response);
36
- } catch (error) {
37
- handleErrorResponse(error);
38
- }
39
- };
40
-
41
- const handleErrorResponse = (error) => {
42
- if (error.meta && error.meta.body) {
43
- console.error('Error:', error.meta.body.error);
44
- } else {
45
- console.error('Error:', error.message);
46
- }
47
- };
48
-
49
- const createMoviesIndex = async () => {
50
- try {
51
- const response = await client.indices.create({
52
- index: 'movies',
53
- body: {
54
- mappings: {
55
- properties: {
56
- title: { type: 'text' },
57
- director: { type: 'text' },
58
- year: { type: 'integer' },
59
- },
60
- },
61
- },
62
- });
63
-
64
- printResponse('Create `movies` Index', response);
65
- } catch (error) {
66
- handleErrorResponse(error);
67
- }
68
- };
69
-
70
- const indexMovies = async () => {
71
- for (let i = 0; i < 10; i++) {
72
- await client.index({
73
- index: 'movies',
74
- id: i,
75
- body: {
76
- title: `The Dark Knight ${i}`,
77
- director: 'Christopher Nolan',
78
- year: 2008 + i,
79
- },
80
- });
81
- }
82
-
83
- await client.index({
84
- index: 'movies',
85
- body: {
86
- title: 'The Godfather',
87
- director: 'Francis Ford Coppola',
88
- year: 1972,
89
- },
90
- });
91
-
92
- await client.index({
93
- index: 'movies',
94
- body: {
95
- title: 'The Shawshank Redemption',
96
- director: 'Frank Darabont',
97
- year: 1994,
98
- },
99
- });
100
- };
101
-
102
- const searchMovies = async (query) => {
103
- const response = await client.search({
104
- index: 'movies',
105
- body: query,
106
- });
107
-
108
- console.log('\nSearch Results:');
109
- response.body.hits.hits.forEach((element) => {
110
- console.log(element._source);
111
- });
112
- };
113
-
114
- const start = async () => {
115
- try {
116
- // Check the cluster health
117
- const clusterHealthResponse = await client.cluster.health({});
118
- printResponse('Get Cluster Health', clusterHealthResponse);
119
-
120
- // Check if the 'movies' index exists
121
- const indexExistsResponse = await client.indices.exists({ index: 'movies' });
122
- if (indexExistsResponse.statusCode === 200) {
123
- // Delete the 'movies' index if it exists
124
- const deleteIndexResponse = await client.indices.delete({ index: 'movies' });
125
- printResponse('Delete existing `movies` Index', deleteIndexResponse);
126
- }
127
-
128
- await createMoviesIndex();
129
- await indexMovies();
130
-
131
- // Refresh the 'movies' index
132
- await refreshIndex('movies');
133
- console.log('\nRefreshed `movies` Index');
134
-
135
- // List all movies using search
136
- await searchMovies({});
137
-
138
- // Search for 'dark knight'
139
- await searchMovies({
140
- query: {
141
- match: {
142
- title: 'dark knight',
143
- },
144
- },
145
- });
146
-
147
- // Delete the movies index
148
- const deleteIndexResponse = await client.indices.delete({ index: 'movies' });
149
- printResponse('Delete `movies` Index', deleteIndexResponse);
150
- } catch (error) {
151
- handleErrorResponse(error);
152
- }
153
- };
154
-
155
- start();
@@ -1,146 +0,0 @@
1
- /*
2
- * Copyright OpenSearch Contributors
3
- * SPDX-License-Identifier: Apache-2.0
4
- *
5
- * The OpenSearch Contributors require contributions made to
6
- * this file be licensed under the Apache-2.0 license or a
7
- * compatible open source license.
8
- *
9
- */
10
-
11
- // const {Client} = require('../index.js')
12
- const { Client } = require('@opensearch-project/opensearch');
13
-
14
- const faker = require('faker');
15
-
16
- // Instantiate a client with basic auth as setup in the README.md file
17
- const client = new Client({
18
- ssl: {
19
- rejectUnauthorized: false,
20
- },
21
- node: 'https://localhost:9200',
22
- auth: {
23
- username: 'admin',
24
- password: 'myStrongPassword123!',
25
- },
26
- });
27
-
28
- const start = async () => {
29
- const sourceIndex = 'sample-index';
30
- const transformIndex = 'transform-index';
31
- const transformJob = 'my-transform-job';
32
-
33
- /////////////////// SETUP //////////////////
34
- // Create source index
35
- await client.indices.create({
36
- index: sourceIndex,
37
- body: {
38
- mappings: {
39
- properties: {
40
- name: { type: 'keyword' },
41
- age: { type: 'integer' },
42
- gender: { type: 'keyword' },
43
- salary: { type: 'integer' },
44
- },
45
- },
46
- },
47
- });
48
-
49
- // Create 100 documents
50
- for (let i = 0; i < 100; i++) {
51
- // Generate random data for each field
52
- const name = faker.name.findName(); // generates a random name
53
- const age = faker.datatype.number({ min: 20, max: 60 }); // generates a random age between 20 and 60
54
- const gender = faker.random.arrayElement(['Male', 'Female']); // randomly selects 'Male' or 'Female'
55
- const salary = faker.datatype.number({ min: 30000, max: 100000 }); // generates a random salary between 30000 and 100000
56
-
57
- // Index the document
58
- await client.index({
59
- index: sourceIndex,
60
- body: {
61
- name,
62
- age,
63
- gender,
64
- salary,
65
- },
66
- });
67
- }
68
-
69
- // Refresh the index to make sure all documents are searchable
70
- await client.indices.refresh({ index: sourceIndex });
71
-
72
- //////////// TRANSFORM OPERATIONS ////////////
73
- // Create transform
74
- await client.transforms.put({
75
- id: transformJob,
76
- body: {
77
- transform: {
78
- enabled: true,
79
- continuous: true,
80
- schedule: {
81
- interval: {
82
- period: 1,
83
- unit: 'Minutes',
84
- start_time: 0
85
- }
86
- },
87
- description: 'Sample transform job',
88
- source_index: sourceIndex,
89
- target_index: transformIndex,
90
- data_selection_query: {
91
- match_all: {}
92
- },
93
- page_size: 1,
94
- groups: [
95
- {
96
- terms: {
97
- source_field: 'gender',
98
- target_field: 'gender'
99
- }
100
- },
101
- {
102
- terms: {
103
- source_field: 'age',
104
- target_field: 'age'
105
- }
106
- }
107
- ],
108
- aggregations: {
109
- quantity: {
110
- sum: {
111
- field: 'salary'
112
- }
113
- }
114
- }
115
- }
116
- },
117
- });
118
-
119
- // Start transform
120
- await client.transforms.start({ id: transformJob });
121
-
122
- // Get transform
123
- const transform = await client.transforms.get({ id: transformJob });
124
- console.log(transform.body);
125
-
126
- // Wait till the transform index is created
127
- while (!(await client.indices.exists({ index: transformIndex })).body) {
128
- await new Promise((resolve) => setTimeout(resolve, 5000));
129
- }
130
-
131
- // Get transform status
132
- const explain = await client.transforms.explain({ id: transformJob });
133
- console.log(explain.body);
134
-
135
- // Stop transform
136
- await client.transforms.stop({ id: transformJob });
137
-
138
- // Delete the transform job
139
- await client.transforms.delete({ id: transformJob });
140
-
141
- ///////////////// TEAR DOWN ///////////////
142
- await client.indices.delete({ index: sourceIndex });
143
- // await client.indices.delete({ index: transformIndex });
144
- };
145
-
146
- start().then(() => console.log('done'));