@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.
Files changed (83) hide show
  1. package/.eslintrc.json +4 -1
  2. package/CHANGELOG.md +125 -6
  3. package/DEVELOPER_GUIDE.md +55 -5
  4. package/MAINTAINERS.md +10 -6
  5. package/RELEASING.md +8 -1
  6. package/USER_GUIDE.md +133 -63
  7. package/api/api/bulk.js +23 -0
  8. package/api/api/cat.js +319 -0
  9. package/api/api/clear_scroll.js +14 -0
  10. package/api/api/cluster.js +237 -0
  11. package/api/api/count.js +28 -0
  12. package/api/api/create.js +26 -0
  13. package/api/api/create_pit.js +88 -0
  14. package/api/api/dangling_indices.js +45 -0
  15. package/api/api/delete.js +23 -0
  16. package/api/api/delete_all_pits.js +53 -0
  17. package/api/api/delete_by_query.js +48 -0
  18. package/api/api/delete_by_query_rethrottle.js +14 -0
  19. package/api/api/delete_pit.js +61 -0
  20. package/api/api/delete_script.js +14 -0
  21. package/api/api/exists.js +25 -0
  22. package/api/api/exists_source.js +25 -0
  23. package/api/api/explain.js +27 -0
  24. package/api/api/features.js +24 -0
  25. package/api/api/field_caps.js +19 -0
  26. package/api/api/get.js +25 -0
  27. package/api/api/get_all_pits.js +53 -0
  28. package/api/api/get_script.js +16 -0
  29. package/api/api/get_script_context.js +11 -0
  30. package/api/api/get_script_languages.js +11 -0
  31. package/api/api/get_source.js +25 -0
  32. package/api/api/index.js +29 -0
  33. package/api/api/indices.js +815 -0
  34. package/api/api/info.js +11 -0
  35. package/api/api/ingest.js +89 -0
  36. package/api/api/mget.js +24 -0
  37. package/api/api/msearch.js +22 -0
  38. package/api/api/msearch_template.js +19 -0
  39. package/api/api/nodes.js +91 -0
  40. package/api/api/ping.js +11 -0
  41. package/api/api/put_script.js +17 -0
  42. package/api/api/rank_eval.js +19 -0
  43. package/api/api/reindex.js +22 -0
  44. package/api/api/reindex_rethrottle.js +14 -0
  45. package/api/api/render_search_template.js +14 -0
  46. package/api/api/scripts_painless_execute.js +13 -0
  47. package/api/api/scroll.js +17 -0
  48. package/api/api/search.js +60 -0
  49. package/api/api/search_shards.js +19 -0
  50. package/api/api/search_template.js +27 -0
  51. package/api/api/shutdown.js +3 -0
  52. package/api/api/snapshot.js +210 -0
  53. package/api/api/tasks.js +56 -0
  54. package/api/api/terms_enum.js +1 -0
  55. package/api/api/termvectors.js +26 -0
  56. package/api/api/update.js +28 -0
  57. package/api/api/update_by_query.js +50 -0
  58. package/api/api/update_by_query_rethrottle.js +14 -0
  59. package/api/index.js +28 -0
  60. package/api/new.d.ts +64 -0
  61. package/api/opensearch_dashboards.d.ts +4 -0
  62. package/api/requestParams.d.ts +16 -0
  63. package/api/types.d.ts +53 -6
  64. package/guides/advanced_index_actions.md +91 -0
  65. package/guides/bulk.md +166 -0
  66. package/guides/document_lifecycle.md +162 -0
  67. package/guides/index_lifecycle.md +152 -0
  68. package/guides/index_template.md +228 -0
  69. package/guides/search.md +217 -0
  70. package/index.d.ts +160 -0
  71. package/jenkins/release.JenkinsFile +2 -2
  72. package/lib/Connection.js +1 -1
  73. package/lib/Serializer.js +2 -2
  74. package/lib/Transport.js +23 -1
  75. package/lib/aws/AwsSigv4Signer.js +14 -5
  76. package/lib/aws/index.d.ts +1 -0
  77. package/lib/errors.d.ts +2 -2
  78. package/lib/errors.js +2 -2
  79. package/lib/pool/BaseConnectionPool.js +18 -9
  80. package/lib/pool/CloudConnectionPool.js +2 -2
  81. package/lib/pool/ConnectionPool.js +4 -4
  82. package/lib/pool/index.d.ts +35 -6
  83. package/package.json +13 -12
@@ -98,6 +98,54 @@ const snakeCase = {
98
98
  filterPath: 'filter_path',
99
99
  };
100
100
 
101
+ /**
102
+ * Deletes documents matching the provided query.
103
+ * <br/> See Also: {@link https://opensearch.org/docs/2.4/api-reference/document-apis/delete-by-query/ OpenSearch - Delete by query}
104
+ *
105
+ * @memberOf API-Document
106
+ *
107
+ * @param {Object} params
108
+ * @param {string} params.index - A comma-separated list of index names to search; use '_all' or empty string to perform the operation on all indices
109
+ * @param {Object} params.body - The search definition using the Query DSL
110
+ * @param {string} [params.analyzer] - The analyzer to use for the query string
111
+ * @param {boolean} [params.analyze_wildcard=false] - Specify whether wildcard and prefix queries should be analyzed
112
+ * @param {string} [params.default_operator=OR] - The default operator for query string query (options: AND, OR)
113
+ * @param {string} [params.df] - The field to use as default where no field prefix is given in the query string
114
+ * @param {number} [params.from=0] - Starting offset
115
+ * @param {boolean} [params.ignore_unavailable=false] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
116
+ * @param {boolean} [params.allow_no_indices=true] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes '_all' string or when no indices have been specified)
117
+ * @param {string} [params.conflicts] - What to do when the delete-by-query hits version conflicts? (options: abort, proceed)
118
+ * @param {string} [params.expand_wildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
119
+ * @param {boolean} [params.lenient=false] - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
120
+ * @param {string} [params.preference] - Specify the node or shard the operation should be performed on (default: random)
121
+ * @param {string} [params.q] - Query in the Lucene query string syntax
122
+ * @param {string} [params.routing] - A comma-separated list of specific routing values
123
+ * @param {string} [params.scroll] - Specify how long a consistent view of the index should be maintained for scrolled search
124
+ * @param {string} [params.search_type] - Search operation type (options: query_then_fetch, dfs_query_then_fetch)
125
+ * @param {string} [params.search_timeout] - Explicit timeout for each search request. Defaults to no timeout.
126
+ * @param {number} [params.size] - Deprecated, please use 'max_docs' instead
127
+ * @param {number} [params.max_docs] - Maximum number of documents to process (default: all documents)
128
+ * @param {string} [params.sort] - A comma-separated list of <field>:<direction> pairs
129
+ * @param {string} [params._source] - True or false to return the _source field or not, or a list of fields to return
130
+ * @param {string} [params._source_excludes] - A list of fields to exclude from the returned _source field
131
+ * @param {string} [params._source_includes] - A list of fields to extract and return from the _source field
132
+ * @param {number} [params.terminate_after] - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
133
+ * @param {string} [params.stats] - Specific 'tag' of the request for logging and statistical purposes
134
+ * @param {boolean} [params.version] - Specify whether to return document version as part of a hit
135
+ * @param {boolean} [params.request_cache] - Specify if request cache should be used for this request or not, defaults to index level setting
136
+ * @param {boolean} [params.refresh=false] - Should the effected indexes be refreshed?
137
+ * @param {string} [params.timeout=1m] - time each individual bulk request should wait for shards that are unavailable.
138
+ * @param {string} [params.wait_for_active_shards=1] - Sets the number of shard copies that must be active before proceeding with the delete-by-query operation. 1 means the primary shard only. Set to 'all' for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
139
+ * @param {number} [params.scroll_size=1000] - Size on the scroll request powering the delete-by-query
140
+ * @param {boolean} [params.wait_for_completion] - Should the request should block until the delete-by-query is complete.
141
+ * @param {number} [params.requests_per_second=-1] - The throttle for this request in sub-requests per second. -1 means no throttle.
142
+ * @param {string} [params.slices=1] - The number of slices this task should be divided into. 1 means the task isn't sliced into subtasks. Can be set to 'auto'.
143
+ *
144
+ * @param {Object} options - Options for {@link Transport#request}
145
+ * @param {function} callback - Callback that handles errors and response
146
+ *
147
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/2.4/api-reference/document-apis/delete-by-query/#response Delete by query Response}
148
+ */
101
149
  function deleteByQueryApi(params, options, callback) {
102
150
  [params, options, callback] = normalizeArguments(params, options, callback);
103
151
 
@@ -47,6 +47,20 @@ const snakeCase = {
47
47
  filterPath: 'filter_path',
48
48
  };
49
49
 
50
+ /**
51
+ * Changes the number of requests per second for a particular Delete By Query operation.
52
+ *
53
+ * @memberOf API-Document
54
+ *
55
+ * @param {Object} params
56
+ * @param {string} params.task_id - The task id to rethrottle
57
+ * @param {number} params.requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
58
+ *
59
+ * @param {Object} options - Options for {@link Transport#request}
60
+ * @param {function} callback - Callback that handles errors and response
61
+ *
62
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
63
+ */
50
64
  function deleteByQueryRethrottleApi(params, options, callback) {
51
65
  [params, options, callback] = normalizeArguments(params, options, callback);
52
66
 
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * The OpenSearch Contributors require contributions made to
6
+ * this file be licensed under the Apache-2.0 license or a
7
+ * compatible open source license.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ /* eslint camelcase: 0 */
14
+ /* eslint no-unused-vars: 0 */
15
+
16
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
17
+ const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
18
+ const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
19
+
20
+ /**
21
+ * Deletes one or several PITs. PITs are automatically deleted when the keep_alive time period elapses. However, to deallocate resources, you can delete a PIT using the Delete PIT API.
22
+ * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#delete-pits|Opensearch - Delete PITs}
23
+ * @memberOf API-PIT
24
+ *
25
+ * @param {Object} params
26
+ * @param {Object} params.body
27
+ * @param {string[]} params.body.pit_id - The PIT IDs of the PITs to be deleted.
28
+ *
29
+ * @param {Object} [options] - Options for {@link Transport#request}
30
+ * @param {function} [callback] - Callback that handles errors and response
31
+ *
32
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#sample-response-2|Delete PIT Response}
33
+ */
34
+ function deletePitApi(params, options, callback) {
35
+ [params, options, callback] = normalizeArguments(params, options, callback);
36
+
37
+ // check required parameters
38
+ if (params['body'] == null) {
39
+ const err = new this[kConfigurationError]('Missing required parameter: body');
40
+ return handleError(err, callback);
41
+ }
42
+
43
+ let { method, body, ...querystring } = params;
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
45
+
46
+ let path = '';
47
+ if (method == null) method = 'DELETE';
48
+ path = '/' + '_search' + '/' + 'point_in_time';
49
+
50
+ // build request object
51
+ const request = {
52
+ method,
53
+ path,
54
+ body: body || '',
55
+ querystring,
56
+ };
57
+
58
+ return this.transport.request(request, options, callback);
59
+ }
60
+
61
+ module.exports = deletePitApi;
@@ -50,6 +50,20 @@ const snakeCase = {
50
50
  filterPath: 'filter_path',
51
51
  };
52
52
 
53
+ /**
54
+ * Delete a stored script.
55
+ * @memberOf API-Script
56
+ *
57
+ * @param {Object} params
58
+ * @param {string} params.id - Stored script or search template name
59
+ * @param {string} [params.timeout=30s] - Explicit operation timeout
60
+ * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
61
+ *
62
+ * @param {Object} [options] - Options for {@link Transport#request}
63
+ * @param {function} [callback] - Callback that handles errors and response
64
+ *
65
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
66
+ */
53
67
  function deleteScriptApi(params, options, callback) {
54
68
  [params, options, callback] = normalizeArguments(params, options, callback);
55
69
 
package/api/api/exists.js CHANGED
@@ -63,6 +63,31 @@ const snakeCase = {
63
63
  filterPath: 'filter_path',
64
64
  };
65
65
 
66
+ /**
67
+ * Check whether a document exists
68
+ * <br/> See Also: {@link https://opensearch.org/docs/2.4/api-reference/document-apis/get-documents/ OpenSearch - Get Document}
69
+ *
70
+ * @memberOf API-Document
71
+ *
72
+ * @param {Object} params
73
+ * @param {string} params.index - Name of the index.
74
+ * @param {string} params.id - Document ID.
75
+ * @param {string} [params.preference] - Specifies a preference of which shard to retrieve results from. Available options are '_local', which tells the operation to retrieve results from a locally allocated shard replica, and a custom string value assigned to a specific shard replica. By default, OpenSearch executes get document operations on random shards.
76
+ * @param {boolean} [params.realtime=true] - Specifies whether the operation should run in realtime. If false, the operation waits for the index to refresh to analyze the source to retrieve data, which makes the operation near-realtime.
77
+ * @param {boolean} [params.refresh=false] - If true, OpenSearch refreshes shards to make the get operation available to search results. Valid options are 'true', 'false', and 'wait_for', which tells OpenSearch to wait for a refresh before executing the operation.
78
+ * @param {string} [params.routing] - A value used to route the operation to a specific shard.
79
+ * @param {boolean} [params.stored_fields=false] - Whether the get operation should retrieve fields stored in the index.
80
+ * @param {string} [params._source=true] - Whether to include the '_source' field in the response body.
81
+ * @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude in the query response.
82
+ * @param {string} [params._source_includes] - A comma-separated list of source fields to include in the query response.
83
+ * @param {number} [params.version] - The document’s version number.
84
+ * @param {number} [params.version_type] - Specific version type (options: 'external' and 'external_gte')
85
+ *
86
+ * @param {Object} options - Options for {@link Transport#request}
87
+ * @param {function} callback - Callback that handles errors and response
88
+ *
89
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/2.4/api-reference/document-apis/get-documents/#response Get Response}
90
+ */
66
91
  function existsApi(params, options, callback) {
67
92
  [params, options, callback] = normalizeArguments(params, options, callback);
68
93
 
@@ -32,6 +32,31 @@
32
32
  /* eslint camelcase: 0 */
33
33
  /* eslint no-unused-vars: 0 */
34
34
 
35
+ /**
36
+ * Check whether a document source exists
37
+ * <br/> See Also: {@link https://opensearch.org/docs/2.4/api-reference/document-apis/get-documents/ OpenSearch - Get Document}
38
+ *
39
+ * @memberOf API-Document
40
+ *
41
+ * @param {Object} params
42
+ * @param {string} params.index - Name of the index.
43
+ * @param {string} params.id - Document ID.
44
+ * @param {string} [params.preference] - Specifies a preference of which shard to retrieve results from. Available options are '_local', which tells the operation to retrieve results from a locally allocated shard replica, and a custom string value assigned to a specific shard replica. By default, OpenSearch executes get document operations on random shards.
45
+ * @param {boolean} [params.realtime=true] - Specifies whether the operation should run in realtime. If false, the operation waits for the index to refresh to analyze the source to retrieve data, which makes the operation near-realtime.
46
+ * @param {boolean} [params.refresh=false] - If true, OpenSearch refreshes shards to make the get operation available to search results. Valid options are 'true', 'false', and 'wait_for', which tells OpenSearch to wait for a refresh before executing the operation.
47
+ * @param {string} [params.routing] - A value used to route the operation to a specific shard.
48
+ * @param {boolean} [params.stored_fields=false] - Whether the get operation should retrieve fields stored in the index.
49
+ * @param {string} [params._source=true] - Whether to include the '_source' field in the response body.
50
+ * @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude in the query response.
51
+ * @param {string} [params._source_includes] - A comma-separated list of source fields to include in the query response.
52
+ * @param {number} [params.version] - The document’s version number.
53
+ * @param {number} [params.version_type] - Specific version type (options: 'external' and 'external_gte')
54
+ *
55
+ * @param {Object} options - Options for {@link Transport#request}
56
+ * @param {function} callback - Callback that handles errors and response
57
+ *
58
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/2.4/api-reference/document-apis/get-documents/#response Get Response}
59
+ */
35
60
  const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
61
  const acceptedQuerystring = [
37
62
  'preference',
@@ -66,6 +66,33 @@ const snakeCase = {
66
66
  filterPath: 'filter_path',
67
67
  };
68
68
 
69
+ /**
70
+ * Returns information about why a specific matches (or doesn't match) a query.
71
+ * <br/> See also: {@link https://opensearch.org/docs/latest/api-reference/explain/ OpenSearch - Explain}
72
+ * @memberOf API-Search
73
+ *
74
+ * @param {Object} params
75
+ * @param {string} [params.id] - The document ID
76
+ * @param {string} [params.index] - The name of the index
77
+ * @param {Object} [params.body] - The query definition using the Query DSL
78
+ * @param {string} [params.analyzer] - The analyzer to use for the query string
79
+ * @param {boolean} [params.analyze_wildcard=false] - Specify whether wildcard and prefix queries should be analyzed
80
+ * @param {string} [params.default_operator=OR] - The default operator for query string query (options: AND, OR)
81
+ * @param {string} [params.df] - The default field for query string query (default: _all)
82
+ * @param {string} [params.stored_fields] - A comma-separated list of stored fields to return in the response
83
+ * @param {boolean} [params.lenient] - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
84
+ * @param {string} [params.preference] - Specify the node or shard the operation should be performed on (default: random)
85
+ * @param {string} [params.q] - Query in the Lucene query string syntax
86
+ * @param {string} [params.routing] - Specific routing value
87
+ * @param {string} [params._source=true] - Whether to include the '_source' field in the response body.
88
+ * @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude in the query response.
89
+ * @param {string} [params._source_includes] - A comma-separated list of source fields to include in the query response.
90
+ *
91
+ * @param {Object} [options] - Options for {@link Transport#request}
92
+ * @param {function} [callback] - Callback that handles errors and response
93
+ *
94
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
95
+ */
69
96
  function explainApi(params, options, callback) {
70
97
  [params, options, callback] = normalizeArguments(params, options, callback);
71
98
 
@@ -32,6 +32,8 @@
32
32
  /* eslint camelcase: 0 */
33
33
  /* eslint no-unused-vars: 0 */
34
34
 
35
+ /** @namespace API-Features */
36
+
35
37
  const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
38
  const acceptedQuerystring = [
37
39
  'cluster_manager_timeout',
@@ -54,6 +56,18 @@ function FeaturesApi(transport, ConfigurationError) {
54
56
  this[kConfigurationError] = ConfigurationError;
55
57
  }
56
58
 
59
+ /**
60
+ * Gets a list of features
61
+ * @memberOf API-Features
62
+ *
63
+ * @param {Object} params
64
+ * @param {string} [params.cluster_manager_timeout] - Explicit operation timeout for connection to cluster_manager node
65
+ *
66
+ * @param {Object} [options] - Options for {@link Transport#request}
67
+ * @param {function} [callback] - Callback that handles errors and response
68
+ *
69
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
70
+ */
57
71
  FeaturesApi.prototype.getFeatures = function featuresGetFeaturesApi(params, options, callback) {
58
72
  [params, options, callback] = normalizeArguments(params, options, callback);
59
73
 
@@ -75,6 +89,16 @@ FeaturesApi.prototype.getFeatures = function featuresGetFeaturesApi(params, opti
75
89
  return this.transport.request(request, options, callback);
76
90
  };
77
91
 
92
+ /**
93
+ * Resets the internal state of features, usually by deleting system indices
94
+ * @memberOf API-Features
95
+ *
96
+ * @param {Object} params - (Unused)
97
+ * @param {Object} [options] - Options for {@link Transport#request}
98
+ * @param {function} [callback] - Callback that handles errors and response
99
+ *
100
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
101
+ */
78
102
  FeaturesApi.prototype.resetFeatures = function featuresResetFeaturesApi(params, options, callback) {
79
103
  [params, options, callback] = normalizeArguments(params, options, callback);
80
104
 
@@ -54,6 +54,25 @@ const snakeCase = {
54
54
  filterPath: 'filter_path',
55
55
  };
56
56
 
57
+ /**
58
+ * Returns the information about the capabilities of fields among multiple indices.
59
+ * <br/> See also: {@link https://opensearch.org/docs/latest/opensearch/supported-field-types/alias/#using-aliases-in-field-capabilities-api-operations OpenSearch - Alias}
60
+ * @memberOf API-Index
61
+ *
62
+ * @param {Object} params
63
+ * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
64
+ * @param {string} [params.fields] - A comma-separated list of field names
65
+ * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
66
+ * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
67
+ * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
68
+ * @param {boolean} [params.include_unmapped] - Indicates whether unmapped fields should be included in the response.
69
+ * @param {Object} [params.body] - An index filter specified with the Query DSL
70
+ *
71
+ * @param {Object} [options] - Options for {@link Transport#request}
72
+ * @param {function} [callback] - Callback that handles errors and response
73
+ *
74
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
75
+ */
57
76
  function fieldCapsApi(params, options, callback) {
58
77
  [params, options, callback] = normalizeArguments(params, options, callback);
59
78
 
package/api/api/get.js CHANGED
@@ -63,6 +63,31 @@ const snakeCase = {
63
63
  filterPath: 'filter_path',
64
64
  };
65
65
 
66
+ /**
67
+ * Retrieve a document
68
+ * <br/> See Also: {@link https://opensearch.org/docs/2.4/api-reference/document-apis/get-documents/ OpenSearch - Get Document}
69
+ *
70
+ * @memberOf API-Document
71
+ *
72
+ * @param {Object} params
73
+ * @param {string} params.index - Name of the index.
74
+ * @param {string} params.id - Document ID.
75
+ * @param {string} [params.preference] - Specifies a preference of which shard to retrieve results from. Available options are '_local', which tells the operation to retrieve results from a locally allocated shard replica, and a custom string value assigned to a specific shard replica. By default, OpenSearch executes get document operations on random shards.
76
+ * @param {boolean} [params.realtime=true] - Specifies whether the operation should run in realtime. If false, the operation waits for the index to refresh to analyze the source to retrieve data, which makes the operation near-realtime.
77
+ * @param {boolean} [params.refresh=false] - If true, OpenSearch refreshes shards to make the get operation available to search results. Valid options are 'true', 'false', and 'wait_for', which tells OpenSearch to wait for a refresh before executing the operation.
78
+ * @param {string} [params.routing] - A value used to route the operation to a specific shard.
79
+ * @param {boolean} [params.stored_fields=false] - Whether the get operation should retrieve fields stored in the index.
80
+ * @param {string} [params._source=true] - Whether to include the '_source' field in the response body.
81
+ * @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude in the query response.
82
+ * @param {string} [params._source_includes] - A comma-separated list of source fields to include in the query response.
83
+ * @param {number} [params.version] - The document’s version number.
84
+ * @param {number} [params.version_type] - Specific version type (options: 'external' and 'external_gte')
85
+ *
86
+ * @param {Object} options - Options for {@link Transport#request}
87
+ * @param {function} callback - Callback that handles errors and response
88
+ *
89
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/2.4/api-reference/document-apis/get-documents/#response Get Response}
90
+ */
66
91
  function getApi(params, options, callback) {
67
92
  [params, options, callback] = normalizeArguments(params, options, callback);
68
93
 
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * The OpenSearch Contributors require contributions made to
6
+ * this file be licensed under the Apache-2.0 license or a
7
+ * compatible open source license.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ /* eslint camelcase: 0 */
14
+ /* eslint no-unused-vars: 0 */
15
+
16
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
17
+ const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
18
+ const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
19
+
20
+ /**
21
+ * Returns all PITs in the OpenSearch cluster.
22
+ * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#list-all-pits|Opensearch - List all PITs}
23
+ * @memberOf API-PIT
24
+ *
25
+ * @param {Object} params
26
+ *
27
+ * @param {Object} [options] - Options for {@link Transport#request}
28
+ * @param {function} [callback] - Callback that handles errors and response
29
+ *
30
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/latest/opensearch/point-in-time-api#sample-response-1|List all PITs Response}
31
+ */
32
+ function getAllPitsApi(params, options, callback) {
33
+ [params, options, callback] = normalizeArguments(params, options, callback);
34
+
35
+ let { method, body, ...querystring } = params;
36
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
37
+
38
+ let path = '';
39
+ if (method == null) method = 'GET';
40
+ path = '/' + '_search' + '/' + 'point_in_time' + '/' + '_all';
41
+
42
+ // build request object
43
+ const request = {
44
+ method,
45
+ path,
46
+ body: null,
47
+ querystring,
48
+ };
49
+
50
+ return this.transport.request(request, options, callback);
51
+ }
52
+
53
+ module.exports = getAllPitsApi;
@@ -32,6 +32,8 @@
32
32
  /* eslint camelcase: 0 */
33
33
  /* eslint no-unused-vars: 0 */
34
34
 
35
+ /** @namespace API-Script */
36
+
35
37
  const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
38
  const acceptedQuerystring = [
37
39
  'cluster_manager_timeout',
@@ -49,6 +51,20 @@ const snakeCase = {
49
51
  filterPath: 'filter_path',
50
52
  };
51
53
 
54
+ /**
55
+ * Retrieves a stored script.
56
+ * <br/> See also: {@link https://opensearch.org/docs/latest/api-reference/script-apis/get-stored-script/ OpenSearch - Get Stored Script}
57
+ * @memberOf API-Script
58
+ *
59
+ * @param {Object} params
60
+ * @param {string} params.id - Stored script or search template name
61
+ * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
62
+ *
63
+ * @param {Object} [options] - Options for {@link Transport#request}
64
+ * @param {function} [callback] - Callback that handles errors and response
65
+ *
66
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
67
+ */
52
68
  function getScriptApi(params, options, callback) {
53
69
  [params, options, callback] = normalizeArguments(params, options, callback);
54
70
 
@@ -36,6 +36,17 @@ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } =
36
36
  const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
37
37
  const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
38
38
 
39
+ /**
40
+ * Retrieves all contexts for stored scripts.
41
+ * <br/> See also: {@link https://opensearch.org/docs/latest/api-reference/script-apis/get-script-contexts/ OpenSearch - Get stored script contexts}
42
+ * @memberOf API-Script
43
+ *
44
+ * @param {Object} params - (Unused)
45
+ * @param {Object} [options] - Options for {@link Transport#request}
46
+ * @param {function} [callback] - Callback that handles errors and response
47
+ *
48
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
49
+ */
39
50
  function getScriptContextApi(params, options, callback) {
40
51
  [params, options, callback] = normalizeArguments(params, options, callback);
41
52
 
@@ -36,6 +36,17 @@ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } =
36
36
  const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
37
37
  const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
38
38
 
39
+ /**
40
+ * The get script language API operation retrieves all supported script languages and their contexts.
41
+ * <br/> See also: {@link https://opensearch.org/docs/latest/api-reference/script-apis/get-script-language/ OpenSearch - Get script language}
42
+ * @memberOf API-Script
43
+ *
44
+ * @param {Object} params - (Unused)
45
+ * @param {Object} [options] - Options for {@link Transport#request}
46
+ * @param {function} [callback] - Callback that handles errors and response
47
+ *
48
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
49
+ */
39
50
  function getScriptLanguagesApi(params, options, callback) {
40
51
  [params, options, callback] = normalizeArguments(params, options, callback);
41
52
 
@@ -61,6 +61,31 @@ const snakeCase = {
61
61
  filterPath: 'filter_path',
62
62
  };
63
63
 
64
+ /**
65
+ * Retrieve the source of a document
66
+ * <br/> See Also: {@link https://opensearch.org/docs/2.4/api-reference/document-apis/get-documents/ OpenSearch - Get Document}
67
+ *
68
+ * @memberOf API-Document
69
+ *
70
+ * @param {Object} params
71
+ * @param {string} params.index - Name of the index.
72
+ * @param {string} params.id - Document ID.
73
+ * @param {string} [params.preference] - Specifies a preference of which shard to retrieve results from. Available options are '_local', which tells the operation to retrieve results from a locally allocated shard replica, and a custom string value assigned to a specific shard replica. By default, OpenSearch executes get document operations on random shards.
74
+ * @param {boolean} [params.realtime=true] - Specifies whether the operation should run in realtime. If false, the operation waits for the index to refresh to analyze the source to retrieve data, which makes the operation near-realtime.
75
+ * @param {boolean} [params.refresh=false] - If true, OpenSearch refreshes shards to make the get operation available to search results. Valid options are 'true', 'false', and 'wait_for', which tells OpenSearch to wait for a refresh before executing the operation.
76
+ * @param {string} [params.routing] - A value used to route the operation to a specific shard.
77
+ * @param {boolean} [params.stored_fields=false] - Whether the get operation should retrieve fields stored in the index.
78
+ * @param {string} [params._source=true] - Whether to include the '_source' field in the response body.
79
+ * @param {string} [params._source_excludes] - A comma-separated list of source fields to exclude in the query response.
80
+ * @param {string} [params._source_includes] - A comma-separated list of source fields to include in the query response.
81
+ * @param {number} [params.version] - The document’s version number.
82
+ * @param {number} [params.version_type] - Specific version type (options: 'external' and 'external_gte')
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/2.4/api-reference/document-apis/get-documents/#response Get Response}
88
+ */
64
89
  function getSourceApi(params, options, callback) {
65
90
  [params, options, callback] = normalizeArguments(params, options, callback);
66
91
 
package/api/api/index.js CHANGED
@@ -32,6 +32,8 @@
32
32
  /* eslint camelcase: 0 */
33
33
  /* eslint no-unused-vars: 0 */
34
34
 
35
+ /** @namespace API-Document */
36
+
35
37
  const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
36
38
  const acceptedQuerystring = [
37
39
  'wait_for_active_shards',
@@ -62,6 +64,33 @@ const snakeCase = {
62
64
  filterPath: 'filter_path',
63
65
  };
64
66
 
67
+ /**
68
+ * Adds a document to an index.
69
+ * <br/> See Also: {@link https://opensearch.org/docs/2.4/api-reference/document-apis/index-document/ OpenSearch - Index Document}
70
+ *
71
+ * @memberOf API-Document
72
+ *
73
+ * @param {Object} params
74
+ * @param {string} params.index - Name of the index.
75
+ * @param {Object} params.body - The content of the document.
76
+ * @param {string} [params.id] - A unique identifier to attach to the document.
77
+ * @param {number} [params.if_seq_no] - Only perform the index operation if the document has the specified sequence number.
78
+ * @param {number} [params.if_primary_term] - Only perform the index operation if the document has the specified primary term.
79
+ * @param {string} [params.pipeline] - Route the index operation to a certain pipeline.
80
+ * @param {string} [params.routing] - value used to assign the index operation to a specific shard.
81
+ * @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.
82
+ * @param {string} [params.timeout=1m] - How long to wait for a response from the cluster.
83
+ * @param {number} [params.version] - The document’s version number.
84
+ * @param {number} [params.version_type] - Specific version type (options: 'external' and 'external_gte')
85
+ * @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.
86
+ * @param {boolean} [params.require_alias=false] - Specifies whether the target index must be an index alias.
87
+ *
88
+ * @param {Object} options - Options for {@link Transport#request}
89
+ * @param {function} callback - Callback that handles errors and response
90
+ *
91
+ * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*} {@link https://opensearch.org/docs/2.4/api-reference/document-apis/index-document/#response Index Response}
92
+ */
93
+
65
94
  function indexApi(params, options, callback) {
66
95
  [params, options, callback] = normalizeArguments(params, options, callback);
67
96