@elastic/elasticsearch 7.9.0 → 7.9.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.
- package/api/api/async_search.js +114 -0
- package/api/api/autoscaling.js +147 -0
- package/api/api/bulk.js +55 -98
- package/api/api/cat.js +648 -0
- package/api/api/ccr.js +403 -0
- package/api/api/clear_scroll.js +42 -69
- package/api/api/cluster.js +420 -0
- package/api/api/count.js +49 -98
- package/api/api/create.js +54 -92
- package/api/api/dangling_indices.js +115 -0
- package/api/api/delete.js +50 -89
- package/api/api/delete_by_query.js +55 -135
- package/api/api/delete_by_query_rethrottle.js +45 -74
- package/api/api/delete_script.js +41 -71
- package/api/api/enrich.js +173 -0
- package/api/api/eql.js +119 -0
- package/api/api/exists.js +50 -95
- package/api/api/exists_source.js +58 -101
- package/api/api/explain.js +50 -98
- package/api/api/field_caps.js +42 -78
- package/api/api/get.js +50 -95
- package/api/api/get_script.js +41 -70
- package/api/api/get_script_context.js +37 -64
- package/api/api/get_script_languages.js +37 -64
- package/api/api/get_source.js +50 -93
- package/api/api/graph.js +72 -0
- package/api/api/ilm.js +295 -0
- package/api/api/index.js +56 -98
- package/api/api/indices.js +1656 -0
- package/api/api/info.js +37 -64
- package/api/api/ingest.js +178 -0
- package/api/api/license.js +188 -0
- package/api/api/mget.js +55 -97
- package/api/api/migration.js +60 -0
- package/api/api/ml.js +1842 -0
- package/api/api/monitoring.js +66 -0
- package/api/api/msearch.js +55 -96
- package/api/api/msearch_template.js +55 -92
- package/api/api/mtermvectors.js +49 -91
- package/api/api/nodes.js +202 -0
- package/api/api/ping.js +37 -64
- package/api/api/put_script.js +55 -86
- package/api/api/rank_eval.js +46 -81
- package/api/api/reindex.js +41 -82
- package/api/api/reindex_rethrottle.js +45 -74
- package/api/api/render_search_template.js +42 -69
- package/api/api/rollup.js +278 -0
- package/api/api/scripts_painless_execute.js +37 -64
- package/api/api/scroll.js +42 -74
- package/api/api/search.js +49 -149
- package/api/api/search_shards.js +42 -78
- package/api/api/search_template.js +55 -103
- package/api/api/searchable_snapshots.js +159 -0
- package/api/api/security.js +805 -0
- package/api/api/slm.js +256 -0
- package/api/api/snapshot.js +363 -0
- package/api/api/sql.js +119 -0
- package/api/api/ssl.js +55 -0
- package/api/api/tasks.js +108 -0
- package/api/api/termvectors.js +52 -93
- package/api/api/transform.js +268 -0
- package/api/api/update.js +54 -102
- package/api/api/update_by_query.js +51 -135
- package/api/api/update_by_query_rethrottle.js +45 -74
- package/api/api/watcher.js +311 -0
- package/api/api/xpack.js +76 -0
- package/api/index.js +408 -685
- package/api/requestParams.d.ts +813 -813
- package/api/utils.js +58 -0
- package/index.js +49 -48
- package/lib/Connection.d.ts +1 -1
- package/lib/Connection.js +1 -0
- package/lib/Helpers.js +4 -3
- package/lib/Transport.js +31 -25
- package/package.json +1 -1
- package/api/api/async_search.delete.js +0 -78
- package/api/api/async_search.get.js +0 -82
- package/api/api/async_search.submit.js +0 -147
- package/api/api/autoscaling.delete_autoscaling_policy.js +0 -78
- package/api/api/autoscaling.get_autoscaling_decision.js +0 -72
- package/api/api/autoscaling.get_autoscaling_policy.js +0 -78
- package/api/api/autoscaling.put_autoscaling_policy.js +0 -82
- package/api/api/cat.aliases.js +0 -90
- package/api/api/cat.allocation.js +0 -91
- package/api/api/cat.count.js +0 -87
- package/api/api/cat.fielddata.js +0 -89
- package/api/api/cat.health.js +0 -84
- package/api/api/cat.help.js +0 -79
- package/api/api/cat.indices.js +0 -98
- package/api/api/cat.master.js +0 -85
- package/api/api/cat.ml_data_frame_analytics.js +0 -85
- package/api/api/cat.ml_datafeeds.js +0 -84
- package/api/api/cat.ml_jobs.js +0 -85
- package/api/api/cat.ml_trained_models.js +0 -87
- package/api/api/cat.nodeattrs.js +0 -85
- package/api/api/cat.nodes.js +0 -89
- package/api/api/cat.pending_tasks.js +0 -86
- package/api/api/cat.plugins.js +0 -85
- package/api/api/cat.recovery.js +0 -93
- package/api/api/cat.repositories.js +0 -85
- package/api/api/cat.segments.js +0 -88
- package/api/api/cat.shards.js +0 -92
- package/api/api/cat.snapshots.js +0 -92
- package/api/api/cat.tasks.js +0 -89
- package/api/api/cat.templates.js +0 -90
- package/api/api/cat.thread_pool.js +0 -92
- package/api/api/cat.transforms.js +0 -86
- package/api/api/ccr.delete_auto_follow_pattern.js +0 -78
- package/api/api/ccr.follow.js +0 -82
- package/api/api/ccr.follow_info.js +0 -78
- package/api/api/ccr.follow_stats.js +0 -78
- package/api/api/ccr.forget_follower.js +0 -82
- package/api/api/ccr.get_auto_follow_pattern.js +0 -77
- package/api/api/ccr.pause_auto_follow_pattern.js +0 -78
- package/api/api/ccr.pause_follow.js +0 -78
- package/api/api/ccr.put_auto_follow_pattern.js +0 -82
- package/api/api/ccr.resume_auto_follow_pattern.js +0 -78
- package/api/api/ccr.resume_follow.js +0 -78
- package/api/api/ccr.stats.js +0 -72
- package/api/api/ccr.unfollow.js +0 -78
- package/api/api/cluster.allocation_explain.js +0 -81
- package/api/api/cluster.delete_component_template.js +0 -86
- package/api/api/cluster.delete_voting_config_exclusions.js +0 -79
- package/api/api/cluster.exists_component_template.js +0 -86
- package/api/api/cluster.get_component_template.js +0 -85
- package/api/api/cluster.get_settings.js +0 -84
- package/api/api/cluster.health.js +0 -101
- package/api/api/cluster.pending_tasks.js +0 -81
- package/api/api/cluster.post_voting_config_exclusions.js +0 -82
- package/api/api/cluster.put_component_template.js +0 -91
- package/api/api/cluster.put_settings.js +0 -88
- package/api/api/cluster.remote_info.js +0 -77
- package/api/api/cluster.reroute.js +0 -86
- package/api/api/cluster.state.js +0 -106
- package/api/api/cluster.stats.js +0 -85
- package/api/api/dangling_indices.delete_dangling_index.js +0 -88
- package/api/api/dangling_indices.import_dangling_index.js +0 -88
- package/api/api/dangling_indices.list_dangling_indices.js +0 -77
- package/api/api/enrich.delete_policy.js +0 -78
- package/api/api/enrich.execute_policy.js +0 -78
- package/api/api/enrich.get_policy.js +0 -77
- package/api/api/enrich.put_policy.js +0 -82
- package/api/api/enrich.stats.js +0 -72
- package/api/api/eql.delete.js +0 -78
- package/api/api/eql.get.js +0 -80
- package/api/api/eql.search.js +0 -86
- package/api/api/graph.explore.js +0 -90
- package/api/api/ilm.delete_lifecycle.js +0 -78
- package/api/api/ilm.explain_lifecycle.js +0 -80
- package/api/api/ilm.get_lifecycle.js +0 -77
- package/api/api/ilm.get_status.js +0 -72
- package/api/api/ilm.move_to_step.js +0 -78
- package/api/api/ilm.put_lifecycle.js +0 -78
- package/api/api/ilm.remove_policy.js +0 -78
- package/api/api/ilm.retry.js +0 -78
- package/api/api/ilm.start.js +0 -72
- package/api/api/ilm.stop.js +0 -72
- package/api/api/indices.add_block.js +0 -102
- package/api/api/indices.analyze.js +0 -83
- package/api/api/indices.clear_cache.js +0 -93
- package/api/api/indices.clone.js +0 -98
- package/api/api/indices.close.js +0 -94
- package/api/api/indices.create.js +0 -90
- package/api/api/indices.create_data_stream.js +0 -78
- package/api/api/indices.data_streams_stats.js +0 -77
- package/api/api/indices.delete.js +0 -92
- package/api/api/indices.delete_alias.js +0 -101
- package/api/api/indices.delete_data_stream.js +0 -78
- package/api/api/indices.delete_index_template.js +0 -86
- package/api/api/indices.delete_template.js +0 -86
- package/api/api/indices.exists.js +0 -94
- package/api/api/indices.exists_alias.js +0 -95
- package/api/api/indices.exists_index_template.js +0 -88
- package/api/api/indices.exists_template.js +0 -88
- package/api/api/indices.exists_type.js +0 -100
- package/api/api/indices.flush.js +0 -91
- package/api/api/indices.flush_synced.js +0 -88
- package/api/api/indices.forcemerge.js +0 -93
- package/api/api/indices.freeze.js +0 -87
- package/api/api/indices.get.js +0 -98
- package/api/api/indices.get_alias.js +0 -95
- package/api/api/indices.get_data_stream.js +0 -77
- package/api/api/indices.get_field_mapping.js +0 -105
- package/api/api/indices.get_index_template.js +0 -87
- package/api/api/indices.get_mapping.js +0 -99
- package/api/api/indices.get_settings.js +0 -101
- package/api/api/indices.get_template.js +0 -89
- package/api/api/indices.get_upgrade.js +0 -88
- package/api/api/indices.open.js +0 -94
- package/api/api/indices.put_alias.js +0 -101
- package/api/api/indices.put_index_template.js +0 -91
- package/api/api/indices.put_mapping.js +0 -119
- package/api/api/indices.put_settings.js +0 -101
- package/api/api/indices.put_template.js +0 -93
- package/api/api/indices.recovery.js +0 -85
- package/api/api/indices.refresh.js +0 -88
- package/api/api/indices.reload_search_analyzers.js +0 -82
- package/api/api/indices.resolve_index.js +0 -85
- package/api/api/indices.rollover.js +0 -104
- package/api/api/indices.segments.js +0 -89
- package/api/api/indices.shard_stores.js +0 -89
- package/api/api/indices.shrink.js +0 -100
- package/api/api/indices.simulate_index_template.js +0 -87
- package/api/api/indices.simulate_template.js +0 -86
- package/api/api/indices.split.js +0 -100
- package/api/api/indices.stats.js +0 -104
- package/api/api/indices.unfreeze.js +0 -87
- package/api/api/indices.update_aliases.js +0 -86
- package/api/api/indices.upgrade.js +0 -92
- package/api/api/indices.validate_query.js +0 -109
- package/api/api/ingest.delete_pipeline.js +0 -86
- package/api/api/ingest.get_pipeline.js +0 -84
- package/api/api/ingest.processor_grok.js +0 -77
- package/api/api/ingest.put_pipeline.js +0 -90
- package/api/api/ingest.simulate.js +0 -89
- package/api/api/license.delete.js +0 -72
- package/api/api/license.get.js +0 -73
- package/api/api/license.get_basic_status.js +0 -72
- package/api/api/license.get_trial_status.js +0 -72
- package/api/api/license.post.js +0 -72
- package/api/api/license.post_start_basic.js +0 -72
- package/api/api/license.post_start_trial.js +0 -73
- package/api/api/migration.deprecations.js +0 -77
- package/api/api/ml.close_job.js +0 -81
- package/api/api/ml.delete_calendar.js +0 -78
- package/api/api/ml.delete_calendar_event.js +0 -88
- package/api/api/ml.delete_calendar_job.js +0 -88
- package/api/api/ml.delete_data_frame_analytics.js +0 -79
- package/api/api/ml.delete_datafeed.js +0 -78
- package/api/api/ml.delete_expired_data.js +0 -79
- package/api/api/ml.delete_filter.js +0 -78
- package/api/api/ml.delete_forecast.js +0 -91
- package/api/api/ml.delete_job.js +0 -79
- package/api/api/ml.delete_model_snapshot.js +0 -88
- package/api/api/ml.delete_trained_model.js +0 -78
- package/api/api/ml.estimate_model_memory.js +0 -78
- package/api/api/ml.evaluate_data_frame.js +0 -78
- package/api/api/ml.explain_data_frame_analytics.js +0 -77
- package/api/api/ml.find_file_structure.js +0 -99
- package/api/api/ml.flush_job.js +0 -84
- package/api/api/ml.forecast.js +0 -81
- package/api/api/ml.get_buckets.js +0 -99
- package/api/api/ml.get_calendar_events.js +0 -83
- package/api/api/ml.get_calendars.js +0 -78
- package/api/api/ml.get_categories.js +0 -91
- package/api/api/ml.get_data_frame_analytics.js +0 -80
- package/api/api/ml.get_data_frame_analytics_stats.js +0 -80
- package/api/api/ml.get_datafeed_stats.js +0 -77
- package/api/api/ml.get_datafeeds.js +0 -77
- package/api/api/ml.get_filters.js +0 -78
- package/api/api/ml.get_influencers.js +0 -87
- package/api/api/ml.get_job_stats.js +0 -77
- package/api/api/ml.get_jobs.js +0 -77
- package/api/api/ml.get_model_snapshots.js +0 -94
- package/api/api/ml.get_overall_buckets.js +0 -88
- package/api/api/ml.get_records.js +0 -87
- package/api/api/ml.get_trained_models.js +0 -86
- package/api/api/ml.get_trained_models_stats.js +0 -80
- package/api/api/ml.info.js +0 -72
- package/api/api/ml.open_job.js +0 -78
- package/api/api/ml.post_calendar_events.js +0 -82
- package/api/api/ml.post_data.js +0 -84
- package/api/api/ml.preview_datafeed.js +0 -78
- package/api/api/ml.put_calendar.js +0 -78
- package/api/api/ml.put_calendar_job.js +0 -88
- package/api/api/ml.put_data_frame_analytics.js +0 -82
- package/api/api/ml.put_datafeed.js +0 -88
- package/api/api/ml.put_filter.js +0 -82
- package/api/api/ml.put_job.js +0 -82
- package/api/api/ml.put_trained_model.js +0 -82
- package/api/api/ml.revert_model_snapshot.js +0 -88
- package/api/api/ml.set_upgrade_mode.js +0 -73
- package/api/api/ml.start_data_frame_analytics.js +0 -78
- package/api/api/ml.start_datafeed.js +0 -80
- package/api/api/ml.stop_data_frame_analytics.js +0 -81
- package/api/api/ml.stop_datafeed.js +0 -81
- package/api/api/ml.update_data_frame_analytics.js +0 -82
- package/api/api/ml.update_datafeed.js +0 -88
- package/api/api/ml.update_filter.js +0 -82
- package/api/api/ml.update_job.js +0 -82
- package/api/api/ml.update_model_snapshot.js +0 -92
- package/api/api/ml.validate.js +0 -78
- package/api/api/ml.validate_detector.js +0 -78
- package/api/api/monitoring.bulk.js +0 -87
- package/api/api/nodes.hot_threads.js +0 -98
- package/api/api/nodes.info.js +0 -91
- package/api/api/nodes.reload_secure_settings.js +0 -83
- package/api/api/nodes.stats.js +0 -105
- package/api/api/nodes.usage.js +0 -89
- package/api/api/rollup.delete_job.js +0 -78
- package/api/api/rollup.get_jobs.js +0 -77
- package/api/api/rollup.get_rollup_caps.js +0 -77
- package/api/api/rollup.get_rollup_index_caps.js +0 -78
- package/api/api/rollup.put_job.js +0 -82
- package/api/api/rollup.rollup_search.js +0 -95
- package/api/api/rollup.start_job.js +0 -78
- package/api/api/rollup.stop_job.js +0 -80
- package/api/api/searchable_snapshots.clear_cache.js +0 -83
- package/api/api/searchable_snapshots.mount.js +0 -94
- package/api/api/searchable_snapshots.repository_stats.js +0 -78
- package/api/api/searchable_snapshots.stats.js +0 -77
- package/api/api/security.authenticate.js +0 -72
- package/api/api/security.change_password.js +0 -83
- package/api/api/security.clear_cached_privileges.js +0 -78
- package/api/api/security.clear_cached_realms.js +0 -78
- package/api/api/security.clear_cached_roles.js +0 -78
- package/api/api/security.create_api_key.js +0 -78
- package/api/api/security.delete_privileges.js +0 -88
- package/api/api/security.delete_role.js +0 -78
- package/api/api/security.delete_role_mapping.js +0 -78
- package/api/api/security.delete_user.js +0 -78
- package/api/api/security.disable_user.js +0 -78
- package/api/api/security.enable_user.js +0 -78
- package/api/api/security.get_api_key.js +0 -77
- package/api/api/security.get_builtin_privileges.js +0 -72
- package/api/api/security.get_privileges.js +0 -86
- package/api/api/security.get_role.js +0 -77
- package/api/api/security.get_role_mapping.js +0 -77
- package/api/api/security.get_token.js +0 -78
- package/api/api/security.get_user.js +0 -77
- package/api/api/security.get_user_privileges.js +0 -72
- package/api/api/security.has_privileges.js +0 -83
- package/api/api/security.invalidate_api_key.js +0 -78
- package/api/api/security.invalidate_token.js +0 -78
- package/api/api/security.put_privileges.js +0 -78
- package/api/api/security.put_role.js +0 -82
- package/api/api/security.put_role_mapping.js +0 -82
- package/api/api/security.put_user.js +0 -82
- package/api/api/slm.delete_lifecycle.js +0 -78
- package/api/api/slm.execute_lifecycle.js +0 -78
- package/api/api/slm.execute_retention.js +0 -72
- package/api/api/slm.get_lifecycle.js +0 -77
- package/api/api/slm.get_stats.js +0 -72
- package/api/api/slm.get_status.js +0 -72
- package/api/api/slm.put_lifecycle.js +0 -78
- package/api/api/slm.start.js +0 -72
- package/api/api/slm.stop.js +0 -72
- package/api/api/snapshot.cleanup_repository.js +0 -86
- package/api/api/snapshot.create.js +0 -97
- package/api/api/snapshot.create_repository.js +0 -91
- package/api/api/snapshot.delete.js +0 -95
- package/api/api/snapshot.delete_repository.js +0 -86
- package/api/api/snapshot.get.js +0 -98
- package/api/api/snapshot.get_repository.js +0 -85
- package/api/api/snapshot.restore.js +0 -97
- package/api/api/snapshot.status.js +0 -95
- package/api/api/snapshot.verify_repository.js +0 -86
- package/api/api/sql.clear_cursor.js +0 -78
- package/api/api/sql.query.js +0 -78
- package/api/api/sql.translate.js +0 -78
- package/api/api/ssl.certificates.js +0 -72
- package/api/api/tasks.cancel.js +0 -88
- package/api/api/tasks.get.js +0 -86
- package/api/api/tasks.list.js +0 -87
- package/api/api/transform.delete_transform.js +0 -78
- package/api/api/transform.get_transform.js +0 -79
- package/api/api/transform.get_transform_stats.js +0 -80
- package/api/api/transform.preview_transform.js +0 -78
- package/api/api/transform.put_transform.js +0 -82
- package/api/api/transform.start_transform.js +0 -78
- package/api/api/transform.stop_transform.js +0 -84
- package/api/api/transform.update_transform.js +0 -82
- package/api/api/watcher.ack_watch.js +0 -89
- package/api/api/watcher.activate_watch.js +0 -78
- package/api/api/watcher.deactivate_watch.js +0 -78
- package/api/api/watcher.delete_watch.js +0 -78
- package/api/api/watcher.execute_watch.js +0 -77
- package/api/api/watcher.get_watch.js +0 -78
- package/api/api/watcher.put_watch.js +0 -82
- package/api/api/watcher.start.js +0 -72
- package/api/api/watcher.stats.js +0 -78
- package/api/api/watcher.stop.js +0 -72
- package/api/api/xpack.info.js +0 -73
- package/api/api/xpack.usage.js +0 -72
package/api/utils.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
3
|
+
* license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright
|
|
5
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
6
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
+
* not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
'use strict'
|
|
21
|
+
|
|
22
|
+
const result = { body: null, statusCode: null, headers: null, warnings: null }
|
|
23
|
+
const kConfigurationError = Symbol('configuration error')
|
|
24
|
+
|
|
25
|
+
function handleError (err, callback) {
|
|
26
|
+
if (callback) {
|
|
27
|
+
process.nextTick(callback, err, result)
|
|
28
|
+
return { then: noop, catch: noop, abort: noop }
|
|
29
|
+
}
|
|
30
|
+
return Promise.reject(err)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring) {
|
|
34
|
+
var target = {}
|
|
35
|
+
var keys = Object.keys(querystring)
|
|
36
|
+
for (var i = 0, len = keys.length; i < len; i++) {
|
|
37
|
+
var key = keys[i]
|
|
38
|
+
target[snakeCase[key] || key] = querystring[key]
|
|
39
|
+
}
|
|
40
|
+
return target
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function normalizeArguments (params, options, callback) {
|
|
44
|
+
if (typeof options === 'function') {
|
|
45
|
+
callback = options
|
|
46
|
+
options = {}
|
|
47
|
+
}
|
|
48
|
+
if (typeof params === 'function' || params == null) {
|
|
49
|
+
callback = params
|
|
50
|
+
params = {}
|
|
51
|
+
options = {}
|
|
52
|
+
}
|
|
53
|
+
return [params, options, callback]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function noop () {}
|
|
57
|
+
|
|
58
|
+
module.exports = { handleError, snakeCaseKeys, normalizeArguments, noop, kConfigurationError }
|
package/index.js
CHANGED
|
@@ -17,17 +17,19 @@ const Helpers = nodeMajor < 10 ? /* istanbul ignore next */ null : require('./li
|
|
|
17
17
|
const Serializer = require('./lib/Serializer')
|
|
18
18
|
const errors = require('./lib/errors')
|
|
19
19
|
const { ConfigurationError } = errors
|
|
20
|
+
const { prepareHeaders } = Connection.internals
|
|
20
21
|
|
|
21
22
|
const kInitialOptions = Symbol('elasticsearchjs-initial-options')
|
|
22
23
|
const kChild = Symbol('elasticsearchjs-child')
|
|
23
24
|
const kExtensions = Symbol('elasticsearchjs-extensions')
|
|
24
25
|
const kEventEmitter = Symbol('elasticsearchjs-event-emitter')
|
|
25
26
|
|
|
26
|
-
const
|
|
27
|
+
const ESAPI = require('./api')
|
|
27
28
|
|
|
28
|
-
class Client {
|
|
29
|
+
class Client extends ESAPI {
|
|
29
30
|
constructor (opts = {}) {
|
|
30
|
-
|
|
31
|
+
super({ ConfigurationError })
|
|
32
|
+
if (opts.cloud && opts[kChild] === undefined) {
|
|
31
33
|
const { id, username, password } = opts.cloud
|
|
32
34
|
// the cloud id is `cluster-name:base64encodedurl`
|
|
33
35
|
// the url is a string divided by two '$', the first is the cloud url
|
|
@@ -56,37 +58,41 @@ class Client {
|
|
|
56
58
|
throw new ConfigurationError('Missing node(s) option')
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
if (opts[kChild] === undefined) {
|
|
62
|
+
const checkAuth = getAuth(opts.node || opts.nodes)
|
|
63
|
+
if (checkAuth && checkAuth.username && checkAuth.password) {
|
|
64
|
+
opts.auth = Object.assign({}, opts.auth, { username: checkAuth.username, password: checkAuth.password })
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
const options =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
const options = opts[kChild] !== undefined
|
|
69
|
+
? opts[kChild].initialOptions
|
|
70
|
+
: Object.assign({}, {
|
|
71
|
+
Connection,
|
|
72
|
+
Transport,
|
|
73
|
+
Serializer,
|
|
74
|
+
ConnectionPool: opts.cloud ? CloudConnectionPool : ConnectionPool,
|
|
75
|
+
maxRetries: 3,
|
|
76
|
+
requestTimeout: 30000,
|
|
77
|
+
pingTimeout: 3000,
|
|
78
|
+
sniffInterval: false,
|
|
79
|
+
sniffOnStart: false,
|
|
80
|
+
sniffEndpoint: '_nodes/_all/http',
|
|
81
|
+
sniffOnConnectionFault: false,
|
|
82
|
+
resurrectStrategy: 'ping',
|
|
83
|
+
suggestCompression: false,
|
|
84
|
+
compression: false,
|
|
85
|
+
ssl: null,
|
|
86
|
+
agent: null,
|
|
87
|
+
headers: {},
|
|
88
|
+
nodeFilter: null,
|
|
89
|
+
nodeSelector: 'round-robin',
|
|
90
|
+
generateRequestId: null,
|
|
91
|
+
name: 'elasticsearch-js',
|
|
92
|
+
auth: null,
|
|
93
|
+
opaqueIdPrefix: null,
|
|
94
|
+
context: null
|
|
95
|
+
}, opts)
|
|
90
96
|
|
|
91
97
|
this[kInitialOptions] = options
|
|
92
98
|
this[kExtensions] = []
|
|
@@ -140,17 +146,6 @@ class Client {
|
|
|
140
146
|
if (Helpers !== null) {
|
|
141
147
|
this.helpers = new Helpers({ client: this, maxRetries: options.maxRetries })
|
|
142
148
|
}
|
|
143
|
-
|
|
144
|
-
const apis = buildApi({
|
|
145
|
-
makeRequest: this.transport.request.bind(this.transport),
|
|
146
|
-
result: { body: null, statusCode: null, headers: null, warnings: null },
|
|
147
|
-
ConfigurationError
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
const apiNames = Object.keys(apis)
|
|
151
|
-
for (var i = 0, len = apiNames.length; i < len; i++) {
|
|
152
|
-
this[apiNames[i]] = apis[apiNames[i]]
|
|
153
|
-
}
|
|
154
149
|
}
|
|
155
150
|
|
|
156
151
|
get emit () {
|
|
@@ -186,7 +181,7 @@ class Client {
|
|
|
186
181
|
throw new Error(`The method "${method}" already exists on namespace "${namespace}"`)
|
|
187
182
|
}
|
|
188
183
|
|
|
189
|
-
this[namespace]
|
|
184
|
+
if (this[namespace] == null) this[namespace] = {}
|
|
190
185
|
this[namespace][method] = fn({
|
|
191
186
|
makeRequest: this.transport.request.bind(this.transport),
|
|
192
187
|
result: { body: null, statusCode: null, headers: null, warnings: null },
|
|
@@ -209,15 +204,21 @@ class Client {
|
|
|
209
204
|
|
|
210
205
|
child (opts) {
|
|
211
206
|
// Merge the new options with the initial ones
|
|
212
|
-
const
|
|
207
|
+
const options = Object.assign({}, this[kInitialOptions], opts)
|
|
213
208
|
// Pass to the child client the parent instances that cannot be overriden
|
|
214
|
-
|
|
209
|
+
options[kChild] = {
|
|
215
210
|
connectionPool: this.connectionPool,
|
|
216
211
|
serializer: this.serializer,
|
|
217
|
-
eventEmitter: this[kEventEmitter]
|
|
212
|
+
eventEmitter: this[kEventEmitter],
|
|
213
|
+
initialOptions: options
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* istanbul ignore else */
|
|
217
|
+
if (options.auth !== undefined) {
|
|
218
|
+
options.headers = prepareHeaders(options.headers, options.auth)
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
const client = new Client(
|
|
221
|
+
const client = new Client(options)
|
|
221
222
|
// Add parent extensions
|
|
222
223
|
if (this[kExtensions].length > 0) {
|
|
223
224
|
this[kExtensions].forEach(({ name, opts, fn }) => {
|
package/lib/Connection.d.ts
CHANGED
package/lib/Connection.js
CHANGED
package/lib/Helpers.js
CHANGED
|
@@ -69,7 +69,7 @@ class Helpers {
|
|
|
69
69
|
const { method, body, index, ...querystring } = params
|
|
70
70
|
|
|
71
71
|
let response = null
|
|
72
|
-
for (let i = 0; i
|
|
72
|
+
for (let i = 0; i <= maxRetries; i++) {
|
|
73
73
|
response = await this[kClient].search(params, options)
|
|
74
74
|
if (response.statusCode !== 429) break
|
|
75
75
|
await sleep(wait)
|
|
@@ -99,9 +99,10 @@ class Helpers {
|
|
|
99
99
|
break
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
for (let i = 0; i
|
|
102
|
+
for (let i = 0; i <= maxRetries; i++) {
|
|
103
103
|
response = await this[kClient].scroll({
|
|
104
|
-
|
|
104
|
+
scroll: querystring.scroll,
|
|
105
|
+
rest_total_hits_as_int: querystring.rest_total_hits_as_int || querystring.restTotalHitsAsInt,
|
|
105
106
|
body: { scroll_id }
|
|
106
107
|
}, options)
|
|
107
108
|
if (response.statusCode !== 429) break
|
package/lib/Transport.js
CHANGED
|
@@ -112,25 +112,47 @@ class Transport {
|
|
|
112
112
|
body: null,
|
|
113
113
|
statusCode: null,
|
|
114
114
|
headers: null,
|
|
115
|
-
warnings: options.warnings || null,
|
|
116
115
|
meta
|
|
117
116
|
}
|
|
118
117
|
|
|
118
|
+
Object.defineProperty(result, 'warnings', {
|
|
119
|
+
get () {
|
|
120
|
+
return this.headers && this.headers.warning
|
|
121
|
+
? this.headers.warning.split(/(?!\B"[^"]*),(?![^"]*"\B)/)
|
|
122
|
+
: null
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
|
|
119
126
|
// We should not retry if we are sending a stream body, because we should store in memory
|
|
120
127
|
// a copy of the stream to be able to send it again, but since we don't know in advance
|
|
121
128
|
// the size of the stream, we risk to take too much memory.
|
|
122
129
|
// Furthermore, copying everytime the stream is very a expensive operation.
|
|
123
|
-
const maxRetries = isStream(params.body)
|
|
130
|
+
const maxRetries = isStream(params.body) || isStream(params.bulkBody)
|
|
131
|
+
? 0 : (typeof options.maxRetries === 'number' ? options.maxRetries : this.maxRetries)
|
|
124
132
|
const compression = options.compression !== undefined ? options.compression : this.compression
|
|
125
133
|
var request = { abort: noop }
|
|
134
|
+
const transportReturn = {
|
|
135
|
+
then (onFulfilled, onRejected) {
|
|
136
|
+
return p.then(onFulfilled, onRejected)
|
|
137
|
+
},
|
|
138
|
+
catch (onRejected) {
|
|
139
|
+
return p.catch(onRejected)
|
|
140
|
+
},
|
|
141
|
+
abort () {
|
|
142
|
+
meta.aborted = true
|
|
143
|
+
request.abort()
|
|
144
|
+
debug('Aborting request', params)
|
|
145
|
+
return this
|
|
146
|
+
}
|
|
147
|
+
}
|
|
126
148
|
|
|
127
149
|
const makeRequest = () => {
|
|
128
150
|
if (meta.aborted === true) {
|
|
129
|
-
return callback
|
|
151
|
+
return process.nextTick(callback, new RequestAbortedError(), result)
|
|
130
152
|
}
|
|
131
153
|
meta.connection = this.getConnection({ requestId: meta.request.id })
|
|
132
154
|
if (meta.connection == null) {
|
|
133
|
-
return callback
|
|
155
|
+
return process.nextTick(callback, new NoLivingConnectionsError(), result)
|
|
134
156
|
}
|
|
135
157
|
this.emit('request', null, result)
|
|
136
158
|
// perform the actual http request
|
|
@@ -168,11 +190,6 @@ class Transport {
|
|
|
168
190
|
const { statusCode, headers } = response
|
|
169
191
|
result.statusCode = statusCode
|
|
170
192
|
result.headers = headers
|
|
171
|
-
if (headers['warning'] !== undefined) {
|
|
172
|
-
result.warnings = result.warnings || []
|
|
173
|
-
// split the string over the commas not inside quotes
|
|
174
|
-
result.warnings.push.apply(result.warnings, headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/))
|
|
175
|
-
}
|
|
176
193
|
|
|
177
194
|
if (options.asStream === true) {
|
|
178
195
|
result.body = response
|
|
@@ -265,7 +282,8 @@ class Transport {
|
|
|
265
282
|
try {
|
|
266
283
|
params.body = this.serializer.serialize(params.body)
|
|
267
284
|
} catch (err) {
|
|
268
|
-
|
|
285
|
+
process.nextTick(callback, err, result)
|
|
286
|
+
return transportReturn
|
|
269
287
|
}
|
|
270
288
|
}
|
|
271
289
|
|
|
@@ -279,7 +297,8 @@ class Transport {
|
|
|
279
297
|
try {
|
|
280
298
|
params.body = this.serializer.ndserialize(params.bulkBody)
|
|
281
299
|
} catch (err) {
|
|
282
|
-
|
|
300
|
+
process.nextTick(callback, err, result)
|
|
301
|
+
return transportReturn
|
|
283
302
|
}
|
|
284
303
|
} else {
|
|
285
304
|
params.body = params.bulkBody
|
|
@@ -332,20 +351,7 @@ class Transport {
|
|
|
332
351
|
makeRequest()
|
|
333
352
|
}
|
|
334
353
|
|
|
335
|
-
return
|
|
336
|
-
then (onFulfilled, onRejected) {
|
|
337
|
-
return p.then(onFulfilled, onRejected)
|
|
338
|
-
},
|
|
339
|
-
catch (onRejected) {
|
|
340
|
-
return p.catch(onRejected)
|
|
341
|
-
},
|
|
342
|
-
abort () {
|
|
343
|
-
meta.aborted = true
|
|
344
|
-
request.abort()
|
|
345
|
-
debug('Aborting request', params)
|
|
346
|
-
return this
|
|
347
|
-
}
|
|
348
|
-
}
|
|
354
|
+
return transportReturn
|
|
349
355
|
}
|
|
350
356
|
|
|
351
357
|
getConnection (opts) {
|
package/package.json
CHANGED
|
@@ -1,78 +0,0 @@
|
|
|
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
|
|
@@ -1,82 +0,0 @@
|
|
|
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
|
|
@@ -1,147 +0,0 @@
|
|
|
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
|