Skip to content

Commit 51169d5

Browse files
authored
Support for Elasticsearch 7.7 (#1192)
1 parent be62573 commit 51169d5

File tree

258 files changed

+15894
-1540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+15894
-1540
lines changed

.ci/run-repository.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ echo -e "\033[1m>>>>> NPM run test:integration >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033
3232
repo=$(realpath $(dirname $(realpath -s $0))/../)
3333
run_script_args=""
3434
if [[ "$NODE_JS_VERSION" == "8" ]]; then
35-
run_script_args="-- --node-arg=--harmony-async-iteration"
35+
run_script_args="--harmony-async-iteration"
3636
fi
3737

3838
docker run \
@@ -43,4 +43,4 @@ docker run \
4343
--name elasticsearch-js \
4444
--rm \
4545
elastic/elasticsearch-js \
46-
npm run test:integration ${run_script_args}
46+
node ${run_script_args} test/integration/index.js

.ci/test-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
STACK_VERSION:
3-
- 7.6-SNAPSHOT
3+
- 7.7.0-SNAPSHOT
44

55
NODE_JS_VERSION:
66
- 14

.github/workflows/nodejs.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,42 @@ jobs:
6565
run: |
6666
npm run test:unit -- --node-arg=--harmony-async-iteration
6767
68+
helpers-integration-test:
69+
name: Helpers integration test
70+
runs-on: ubuntu-latest
71+
72+
strategy:
73+
matrix:
74+
node-version: [10.x, 12.x, 14.x]
75+
76+
steps:
77+
- uses: actions/checkout@v2
78+
79+
- name: Configure sysctl limits
80+
run: |
81+
sudo swapoff -a
82+
sudo sysctl -w vm.swappiness=1
83+
sudo sysctl -w fs.file-max=262144
84+
sudo sysctl -w vm.max_map_count=262144
85+
86+
- name: Runs Elasticsearch
87+
uses: elastic/elastic-github-actions/elasticsearch@master
88+
with:
89+
stack-version: 7.7.0-SNAPSHOT
90+
91+
- name: Use Node.js ${{ matrix.node-version }}
92+
uses: actions/setup-node@v1
93+
with:
94+
node-version: ${{ matrix.node-version }}
95+
96+
- name: Install
97+
run: |
98+
npm install
99+
100+
- name: Integration test
101+
run: |
102+
npm run test:integration:helpers
103+
68104
code-coverage:
69105
name: Code coverage
70106
runs-on: ubuntu-latest

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ We recommend that you write a lightweight proxy that uses this client instead.
5252
## Documentation
5353

5454
- [Introduction](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/introduction.html)
55+
- [Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/changelog-client.html)
5556
- [Usage](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-usage.html)
5657
- [Client configuration](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-configuration.html)
5758
- [API reference](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html)
@@ -60,6 +61,7 @@ We recommend that you write a lightweight proxy that uses this client instead.
6061
- [Observability](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/observability.html)
6162
- [Creating a child client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/child-client.html)
6263
- [Extend the client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/extend-client.html)
64+
- [Client helpers](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-helpers.html)
6365
- [Typescript support](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/typescript.html)
6466
- [Testing](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-testing.html)
6567
- [Examples](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/examples.html)

api/api/async_search.delete.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
'use strict'
6+
7+
/* eslint camelcase: 0 */
8+
/* eslint no-unused-vars: 0 */
9+
10+
function buildAsyncSearchDelete (opts) {
11+
// eslint-disable-next-line no-unused-vars
12+
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
13+
14+
const acceptedQuerystring = [
15+
16+
]
17+
18+
const snakeCase = {
19+
20+
}
21+
22+
/**
23+
* Perform a async_search.delete request
24+
* Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
25+
* https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
26+
*/
27+
return function asyncSearchDelete (params, options, callback) {
28+
options = options || {}
29+
if (typeof options === 'function') {
30+
callback = options
31+
options = {}
32+
}
33+
if (typeof params === 'function' || params == null) {
34+
callback = params
35+
params = {}
36+
options = {}
37+
}
38+
39+
// check required parameters
40+
if (params['id'] == null) {
41+
const err = new ConfigurationError('Missing required parameter: id')
42+
return handleError(err, callback)
43+
}
44+
45+
// validate headers object
46+
if (options.headers != null && typeof options.headers !== 'object') {
47+
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
48+
return handleError(err, callback)
49+
}
50+
51+
var warnings = []
52+
var { method, body, id, ...querystring } = params
53+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
54+
55+
var ignore = options.ignore
56+
if (typeof ignore === 'number') {
57+
options.ignore = [ignore]
58+
}
59+
60+
var path = ''
61+
62+
if (method == null) method = 'DELETE'
63+
path = '/' + '_async_search' + '/' + encodeURIComponent(id)
64+
65+
// build request object
66+
const request = {
67+
method,
68+
path,
69+
body: body || '',
70+
querystring
71+
}
72+
73+
options.warnings = warnings.length === 0 ? null : warnings
74+
return makeRequest(request, options, callback)
75+
}
76+
}
77+
78+
module.exports = buildAsyncSearchDelete

api/api/async_search.get.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
'use strict'
6+
7+
/* eslint camelcase: 0 */
8+
/* eslint no-unused-vars: 0 */
9+
10+
function buildAsyncSearchGet (opts) {
11+
// eslint-disable-next-line no-unused-vars
12+
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
13+
14+
const acceptedQuerystring = [
15+
'wait_for_completion_timeout',
16+
'keep_alive',
17+
'typed_keys'
18+
]
19+
20+
const snakeCase = {
21+
waitForCompletionTimeout: 'wait_for_completion_timeout',
22+
keepAlive: 'keep_alive',
23+
typedKeys: 'typed_keys'
24+
}
25+
26+
/**
27+
* Perform a async_search.get request
28+
* Retrieves the results of a previously submitted async search request given its ID.
29+
* https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
30+
*/
31+
return function asyncSearchGet (params, options, callback) {
32+
options = options || {}
33+
if (typeof options === 'function') {
34+
callback = options
35+
options = {}
36+
}
37+
if (typeof params === 'function' || params == null) {
38+
callback = params
39+
params = {}
40+
options = {}
41+
}
42+
43+
// check required parameters
44+
if (params['id'] == null) {
45+
const err = new ConfigurationError('Missing required parameter: id')
46+
return handleError(err, callback)
47+
}
48+
49+
// validate headers object
50+
if (options.headers != null && typeof options.headers !== 'object') {
51+
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
52+
return handleError(err, callback)
53+
}
54+
55+
var warnings = []
56+
var { method, body, id, ...querystring } = params
57+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
58+
59+
var ignore = options.ignore
60+
if (typeof ignore === 'number') {
61+
options.ignore = [ignore]
62+
}
63+
64+
var path = ''
65+
66+
if (method == null) method = 'GET'
67+
path = '/' + '_async_search' + '/' + encodeURIComponent(id)
68+
69+
// build request object
70+
const request = {
71+
method,
72+
path,
73+
body: null,
74+
querystring
75+
}
76+
77+
options.warnings = warnings.length === 0 ? null : warnings
78+
return makeRequest(request, options, callback)
79+
}
80+
}
81+
82+
module.exports = buildAsyncSearchGet

api/api/async_search.submit.js

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
'use strict'
6+
7+
/* eslint camelcase: 0 */
8+
/* eslint no-unused-vars: 0 */
9+
10+
function buildAsyncSearchSubmit (opts) {
11+
// eslint-disable-next-line no-unused-vars
12+
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
13+
14+
const acceptedQuerystring = [
15+
'wait_for_completion_timeout',
16+
'keep_on_completion',
17+
'keep_alive',
18+
'batched_reduce_size',
19+
'request_cache',
20+
'analyzer',
21+
'analyze_wildcard',
22+
'default_operator',
23+
'df',
24+
'explain',
25+
'stored_fields',
26+
'docvalue_fields',
27+
'from',
28+
'ignore_unavailable',
29+
'ignore_throttled',
30+
'allow_no_indices',
31+
'expand_wildcards',
32+
'lenient',
33+
'preference',
34+
'q',
35+
'routing',
36+
'search_type',
37+
'size',
38+
'sort',
39+
'_source',
40+
'_source_excludes',
41+
'_source_exclude',
42+
'_source_includes',
43+
'_source_include',
44+
'terminate_after',
45+
'stats',
46+
'suggest_field',
47+
'suggest_mode',
48+
'suggest_size',
49+
'suggest_text',
50+
'timeout',
51+
'track_scores',
52+
'track_total_hits',
53+
'allow_partial_search_results',
54+
'typed_keys',
55+
'version',
56+
'seq_no_primary_term',
57+
'max_concurrent_shard_requests'
58+
]
59+
60+
const snakeCase = {
61+
waitForCompletionTimeout: 'wait_for_completion_timeout',
62+
keepOnCompletion: 'keep_on_completion',
63+
keepAlive: 'keep_alive',
64+
batchedReduceSize: 'batched_reduce_size',
65+
requestCache: 'request_cache',
66+
analyzeWildcard: 'analyze_wildcard',
67+
defaultOperator: 'default_operator',
68+
storedFields: 'stored_fields',
69+
docvalueFields: 'docvalue_fields',
70+
ignoreUnavailable: 'ignore_unavailable',
71+
ignoreThrottled: 'ignore_throttled',
72+
allowNoIndices: 'allow_no_indices',
73+
expandWildcards: 'expand_wildcards',
74+
searchType: 'search_type',
75+
_sourceExcludes: '_source_excludes',
76+
_sourceExclude: '_source_exclude',
77+
_sourceIncludes: '_source_includes',
78+
_sourceInclude: '_source_include',
79+
terminateAfter: 'terminate_after',
80+
suggestField: 'suggest_field',
81+
suggestMode: 'suggest_mode',
82+
suggestSize: 'suggest_size',
83+
suggestText: 'suggest_text',
84+
trackScores: 'track_scores',
85+
trackTotalHits: 'track_total_hits',
86+
allowPartialSearchResults: 'allow_partial_search_results',
87+
typedKeys: 'typed_keys',
88+
seqNoPrimaryTerm: 'seq_no_primary_term',
89+
maxConcurrentShardRequests: 'max_concurrent_shard_requests'
90+
}
91+
92+
/**
93+
* Perform a async_search.submit request
94+
* Executes a search request asynchronously.
95+
* https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
96+
*/
97+
return function asyncSearchSubmit (params, options, callback) {
98+
options = options || {}
99+
if (typeof options === 'function') {
100+
callback = options
101+
options = {}
102+
}
103+
if (typeof params === 'function' || params == null) {
104+
callback = params
105+
params = {}
106+
options = {}
107+
}
108+
109+
// validate headers object
110+
if (options.headers != null && typeof options.headers !== 'object') {
111+
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
112+
return handleError(err, callback)
113+
}
114+
115+
var warnings = []
116+
var { method, body, index, ...querystring } = params
117+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
118+
119+
var ignore = options.ignore
120+
if (typeof ignore === 'number') {
121+
options.ignore = [ignore]
122+
}
123+
124+
var path = ''
125+
126+
if ((index) != null) {
127+
if (method == null) method = 'POST'
128+
path = '/' + encodeURIComponent(index) + '/' + '_async_search'
129+
} else {
130+
if (method == null) method = 'POST'
131+
path = '/' + '_async_search'
132+
}
133+
134+
// build request object
135+
const request = {
136+
method,
137+
path,
138+
body: body || '',
139+
querystring
140+
}
141+
142+
options.warnings = warnings.length === 0 ? null : warnings
143+
return makeRequest(request, options, callback)
144+
}
145+
}
146+
147+
module.exports = buildAsyncSearchSubmit

0 commit comments

Comments
 (0)