@elastic/elasticsearch 7.11.0 → 7.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +1 -1
  2. package/api/api/async_search.js +11 -11
  3. package/api/api/autoscaling.js +12 -12
  4. package/api/api/bulk.js +4 -4
  5. package/api/api/cat.js +52 -52
  6. package/api/api/ccr.js +40 -40
  7. package/api/api/clear_scroll.js +2 -2
  8. package/api/api/close_point_in_time.js +2 -2
  9. package/api/api/cluster.js +36 -36
  10. package/api/api/count.js +3 -3
  11. package/api/api/create.js +5 -5
  12. package/api/api/dangling_indices.js +8 -8
  13. package/api/api/delete.js +4 -4
  14. package/api/api/delete_by_query.js +5 -5
  15. package/api/api/delete_by_query_rethrottle.js +4 -4
  16. package/api/api/delete_script.js +3 -3
  17. package/api/api/enrich.js +14 -14
  18. package/api/api/eql.js +41 -10
  19. package/api/api/exists.js +4 -4
  20. package/api/api/exists_source.js +6 -6
  21. package/api/api/explain.js +4 -4
  22. package/api/api/features.js +59 -0
  23. package/api/api/field_caps.js +2 -2
  24. package/api/api/get.js +4 -4
  25. package/api/api/get_script.js +3 -3
  26. package/api/api/get_script_context.js +2 -2
  27. package/api/api/get_script_languages.js +2 -2
  28. package/api/api/get_source.js +4 -4
  29. package/api/api/graph.js +4 -4
  30. package/api/api/ilm.js +26 -26
  31. package/api/api/index.js +4 -4
  32. package/api/api/indices.js +162 -162
  33. package/api/api/info.js +2 -2
  34. package/api/api/ingest.js +14 -14
  35. package/api/api/license.js +14 -14
  36. package/api/api/logstash.js +125 -0
  37. package/api/api/mget.js +4 -4
  38. package/api/api/migration.js +2 -2
  39. package/api/api/ml.js +198 -226
  40. package/api/api/monitoring.js +3 -3
  41. package/api/api/msearch.js +4 -4
  42. package/api/api/msearch_template.js +4 -4
  43. package/api/api/mtermvectors.js +3 -3
  44. package/api/api/nodes.js +10 -10
  45. package/api/api/open_point_in_time.js +2 -2
  46. package/api/api/ping.js +2 -2
  47. package/api/api/put_script.js +5 -5
  48. package/api/api/rank_eval.js +3 -3
  49. package/api/api/reindex.js +3 -3
  50. package/api/api/reindex_rethrottle.js +4 -4
  51. package/api/api/render_search_template.js +2 -2
  52. package/api/api/rollup.js +31 -31
  53. package/api/api/scripts_painless_execute.js +2 -2
  54. package/api/api/scroll.js +2 -2
  55. package/api/api/search.js +5 -5
  56. package/api/api/search_shards.js +2 -2
  57. package/api/api/search_template.js +4 -4
  58. package/api/api/searchable_snapshots.js +14 -14
  59. package/api/api/security.js +85 -85
  60. package/api/api/slm.js +21 -21
  61. package/api/api/snapshot.js +46 -46
  62. package/api/api/sql.js +9 -9
  63. package/api/api/ssl.js +2 -2
  64. package/api/api/tasks.js +7 -7
  65. package/api/api/termvectors.js +3 -3
  66. package/api/api/text_structure.js +65 -0
  67. package/api/api/transform.js +25 -25
  68. package/api/api/update.js +5 -5
  69. package/api/api/update_by_query.js +4 -4
  70. package/api/api/update_by_query_rethrottle.js +4 -4
  71. package/api/api/watcher.js +29 -29
  72. package/api/api/xpack.js +4 -4
  73. package/api/index.js +34 -0
  74. package/api/requestParams.d.ts +43 -18
  75. package/api/utils.js +4 -4
  76. package/free-report-junit.xml +13 -0
  77. package/index.d.ts +64 -8
  78. package/index.js +15 -23
  79. package/lib/Connection.js +2 -2
  80. package/lib/Helpers.d.ts +2 -2
  81. package/lib/Helpers.js +11 -6
  82. package/lib/Serializer.js +8 -6
  83. package/lib/Transport.d.ts +1 -0
  84. package/lib/Transport.js +10 -6
  85. package/lib/pool/BaseConnectionPool.js +3 -3
  86. package/lib/pool/ConnectionPool.js +4 -5
  87. package/package.json +23 -23
  88. package/api/kibana.d.ts +0 -485
@@ -299,6 +299,7 @@ export interface CatPlugins extends Generic {
299
299
  master_timeout?: string;
300
300
  h?: string | string[];
301
301
  help?: boolean;
302
+ include_bootstrap?: boolean;
302
303
  s?: string | string[];
303
304
  v?: boolean;
304
305
  }
@@ -731,6 +732,10 @@ export interface EqlGet extends Generic {
731
732
  keep_alive?: string;
732
733
  }
733
734
 
735
+ export interface EqlGetStatus extends Generic {
736
+ id: string;
737
+ }
738
+
734
739
  export interface EqlSearch<T = RequestBody> extends Generic {
735
740
  index: string;
736
741
  wait_for_completion_timeout?: string;
@@ -795,6 +800,10 @@ export interface Explain<T = RequestBody> extends Generic {
795
800
  body?: T;
796
801
  }
797
802
 
803
+ export interface FeaturesGetFeatures extends Generic {
804
+ master_timeout?: string;
805
+ }
806
+
798
807
  export interface FieldCaps<T = RequestBody> extends Generic {
799
808
  index?: string | string[];
800
809
  fields?: string | string[];
@@ -1446,6 +1455,19 @@ export interface LicensePostStartTrial extends Generic {
1446
1455
  acknowledge?: boolean;
1447
1456
  }
1448
1457
 
1458
+ export interface LogstashDeletePipeline extends Generic {
1459
+ id: string;
1460
+ }
1461
+
1462
+ export interface LogstashGetPipeline extends Generic {
1463
+ id: string;
1464
+ }
1465
+
1466
+ export interface LogstashPutPipeline<T = RequestBody> extends Generic {
1467
+ id: string;
1468
+ body: T;
1469
+ }
1470
+
1449
1471
  export interface Mget<T = RequestBody> extends Generic {
1450
1472
  index?: string;
1451
1473
  type?: string;
@@ -1546,24 +1568,6 @@ export interface MlExplainDataFrameAnalytics<T = RequestBody> extends Generic {
1546
1568
  body?: T;
1547
1569
  }
1548
1570
 
1549
- export interface MlFindFileStructure<T = RequestNDBody> extends Generic {
1550
- lines_to_sample?: number;
1551
- line_merge_size_limit?: number;
1552
- timeout?: string;
1553
- charset?: string;
1554
- format?: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text';
1555
- has_header_row?: boolean;
1556
- column_names?: string | string[];
1557
- delimiter?: string;
1558
- quote?: string;
1559
- should_trim_fields?: boolean;
1560
- grok_pattern?: string;
1561
- timestamp_field?: string;
1562
- timestamp_format?: string;
1563
- explain?: boolean;
1564
- body: T;
1565
- }
1566
-
1567
1571
  export interface MlFlushJob<T = RequestBody> extends Generic {
1568
1572
  job_id: string;
1569
1573
  calc_interim?: boolean;
@@ -2136,6 +2140,7 @@ export interface Search<T = RequestBody> extends Generic {
2136
2140
  max_concurrent_shard_requests?: number;
2137
2141
  pre_filter_shard_size?: number;
2138
2142
  rest_total_hits_as_int?: boolean;
2143
+ min_compatible_shard_node?: string;
2139
2144
  body?: T;
2140
2145
  }
2141
2146
 
@@ -2180,6 +2185,7 @@ export interface SearchableSnapshotsMount<T = RequestBody> extends Generic {
2180
2185
  snapshot: string;
2181
2186
  master_timeout?: string;
2182
2187
  wait_for_completion?: boolean;
2188
+ storage?: string;
2183
2189
  body: T;
2184
2190
  }
2185
2191
 
@@ -2189,6 +2195,7 @@ export interface SearchableSnapshotsRepositoryStats extends Generic {
2189
2195
 
2190
2196
  export interface SearchableSnapshotsStats extends Generic {
2191
2197
  index?: string | string[];
2198
+ level?: 'cluster' | 'indices' | 'shards';
2192
2199
  }
2193
2200
 
2194
2201
  export interface SecurityAuthenticate extends Generic {
@@ -2496,6 +2503,24 @@ export interface Termvectors<T = RequestBody> extends Generic {
2496
2503
  body?: T;
2497
2504
  }
2498
2505
 
2506
+ export interface TextStructureFindStructure<T = RequestBody> extends Generic {
2507
+ lines_to_sample?: number;
2508
+ line_merge_size_limit?: number;
2509
+ timeout?: string;
2510
+ charset?: string;
2511
+ format?: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text';
2512
+ has_header_row?: boolean;
2513
+ column_names?: string | string[];
2514
+ delimiter?: string;
2515
+ quote?: string;
2516
+ should_trim_fields?: boolean;
2517
+ grok_pattern?: string;
2518
+ timestamp_field?: string;
2519
+ timestamp_format?: string;
2520
+ explain?: boolean;
2521
+ body: T;
2522
+ }
2523
+
2499
2524
  export interface TransformDeleteTransform extends Generic {
2500
2525
  transform_id: string;
2501
2526
  force?: boolean;
package/api/utils.js CHANGED
@@ -31,10 +31,10 @@ function handleError (err, callback) {
31
31
  }
32
32
 
33
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]
34
+ const target = {}
35
+ const keys = Object.keys(querystring)
36
+ for (let i = 0, len = keys.length; i < len; i++) {
37
+ const key = keys[i]
38
38
  target[snakeCase[key] || key] = querystring[key]
39
39
  }
40
40
  return target
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0"?>
2
+ <testsuites id="2021-03-23T18:11:00.736Z" name="Integration test for Free api" time="2" tests="1" failures="1" skipped="0">
3
+ <testsuite id="2021-03-23T18:11:00.760Z" name="bulk - /bulk/10_basic.yml" time="2" tests="1" failures="1" skipped="0">
4
+ <testcase id="2021-03-23T18:11:00.760Z" name="Array of objects" time="2">
5
+ <failure message="illegal_argument_exception">ResponseError: illegal_argument_exception
6
+ at onBody (/Users/delvedor/Development/elastic/elasticsearch-js-2/lib/Transport.js:337:23)
7
+ at IncomingMessage.onEnd (/Users/delvedor/Development/elastic/elasticsearch-js-2/lib/Transport.js:264:11)
8
+ at IncomingMessage.emit (events.js:327:22)
9
+ at endReadableNT (_stream_readable.js:1327:12)
10
+ at processTicksAndRejections (internal/process/task_queues.js:80:21)</failure>
11
+ </testcase>
12
+ </testsuite>
13
+ </testsuites>
package/index.d.ts CHANGED
@@ -691,6 +691,14 @@ declare class Client {
691
691
  get<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
692
692
  get<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.EqlGet, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
693
693
  get<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.EqlGet, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
694
+ get_status<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.EqlGetStatus, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
695
+ get_status<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
696
+ get_status<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.EqlGetStatus, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
697
+ get_status<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.EqlGetStatus, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
698
+ getStatus<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.EqlGetStatus, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
699
+ getStatus<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
700
+ getStatus<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.EqlGetStatus, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
701
+ getStatus<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.EqlGetStatus, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
694
702
  search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.EqlSearch<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
695
703
  search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
696
704
  search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.EqlSearch<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@@ -712,6 +720,16 @@ declare class Client {
712
720
  explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
713
721
  explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Explain<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
714
722
  explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Explain<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
723
+ features: {
724
+ get_features<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
725
+ get_features<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
726
+ get_features<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
727
+ get_features<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
728
+ getFeatures<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.FeaturesGetFeatures, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
729
+ getFeatures<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
730
+ getFeatures<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
731
+ getFeatures<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.FeaturesGetFeatures, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
732
+ }
715
733
  field_caps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.FieldCaps<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
716
734
  field_caps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
717
735
  field_caps<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.FieldCaps<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@@ -1286,6 +1304,32 @@ declare class Client {
1286
1304
  postStartTrial<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LicensePostStartTrial, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1287
1305
  postStartTrial<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LicensePostStartTrial, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1288
1306
  }
1307
+ logstash: {
1308
+ delete_pipeline<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.LogstashDeletePipeline, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1309
+ delete_pipeline<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1310
+ delete_pipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashDeletePipeline, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1311
+ delete_pipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashDeletePipeline, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1312
+ deletePipeline<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.LogstashDeletePipeline, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1313
+ deletePipeline<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1314
+ deletePipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashDeletePipeline, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1315
+ deletePipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashDeletePipeline, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1316
+ get_pipeline<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.LogstashGetPipeline, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1317
+ get_pipeline<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1318
+ get_pipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashGetPipeline, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1319
+ get_pipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashGetPipeline, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1320
+ getPipeline<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.LogstashGetPipeline, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1321
+ getPipeline<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1322
+ getPipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashGetPipeline, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1323
+ getPipeline<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.LogstashGetPipeline, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1324
+ put_pipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.LogstashPutPipeline<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1325
+ put_pipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1326
+ put_pipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.LogstashPutPipeline<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1327
+ put_pipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.LogstashPutPipeline<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1328
+ putPipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.LogstashPutPipeline<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1329
+ putPipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1330
+ putPipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.LogstashPutPipeline<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1331
+ putPipeline<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.LogstashPutPipeline<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1332
+ }
1289
1333
  mget<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.Mget<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1290
1334
  mget<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1291
1335
  mget<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Mget<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@@ -1417,14 +1461,6 @@ declare class Client {
1417
1461
  explainDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1418
1462
  explainDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlExplainDataFrameAnalytics<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1419
1463
  explainDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlExplainDataFrameAnalytics<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1420
- find_file_structure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(params?: RequestParams.MlFindFileStructure<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1421
- find_file_structure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1422
- find_file_structure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(params: RequestParams.MlFindFileStructure<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1423
- find_file_structure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(params: RequestParams.MlFindFileStructure<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1424
- findFileStructure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(params?: RequestParams.MlFindFileStructure<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1425
- findFileStructure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1426
- findFileStructure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(params: RequestParams.MlFindFileStructure<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1427
- findFileStructure<TResponse = Record<string, any>, TRequestBody extends RequestNDBody = Record<string, any>[], TContext = Context>(params: RequestParams.MlFindFileStructure<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1428
1464
  flush_job<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlFlushJob<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
1429
1465
  flush_job<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
1430
1466
  flush_job<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlFlushJob<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
@@ -2432,6 +2468,26 @@ declare class Client {
2432
2468
  termvectors<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2433
2469
  termvectors<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Termvectors<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2434
2470
  termvectors<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.Termvectors<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2471
+ text_structure: {
2472
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.TextStructureFindStructure<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
2473
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2474
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2475
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2476
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.TextStructureFindStructure<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
2477
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2478
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2479
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2480
+ }
2481
+ textStructure: {
2482
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.TextStructureFindStructure<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
2483
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2484
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2485
+ find_structure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2486
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.TextStructureFindStructure<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
2487
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2488
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2489
+ findStructure<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.TextStructureFindStructure<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
2490
+ }
2435
2491
  transform: {
2436
2492
  delete_transform<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.TransformDeleteTransform, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
2437
2493
  delete_transform<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
package/index.js CHANGED
@@ -27,13 +27,17 @@ const debug = require('debug')('elasticsearch')
27
27
  const Transport = require('./lib/Transport')
28
28
  const Connection = require('./lib/Connection')
29
29
  const { ConnectionPool, CloudConnectionPool } = require('./lib/pool')
30
- // Helpers works only in Node.js >= 10
31
- const Helpers = nodeMajor < 10 ? /* istanbul ignore next */ null : require('./lib/Helpers')
30
+ const Helpers = require('./lib/Helpers')
32
31
  const Serializer = require('./lib/Serializer')
33
32
  const errors = require('./lib/errors')
34
33
  const { ConfigurationError } = errors
35
34
  const { prepareHeaders } = Connection.internals
36
- const clientVersion = require('./package.json').version
35
+ let clientVersion = require('./package.json').version
36
+ /* istanbul ignore next */
37
+ if (clientVersion.includes('-')) {
38
+ // clean prerelease
39
+ clientVersion = clientVersion.slice(0, clientVersion.indexOf('-')) + 'p'
40
+ }
37
41
  const nodeVersion = process.versions.node
38
42
 
39
43
  const kInitialOptions = Symbol('elasticsearchjs-initial-options')
@@ -43,15 +47,6 @@ const kEventEmitter = Symbol('elasticsearchjs-event-emitter')
43
47
 
44
48
  const ESAPI = require('./api')
45
49
 
46
- /* istanbul ignore next */
47
- if (nodeMajor < 10) {
48
- process.emitWarning('You are using a version of Node.js that is currently in EOL. ' +
49
- 'The support for this version will be dropped in 7.12. ' +
50
- 'Please refer to https://ela.st/nodejs-support for additional information.',
51
- 'DeprecationWarning'
52
- )
53
- }
54
-
55
50
  /* istanbul ignore next */
56
51
  if (nodeMajor >= 10 && nodeMajor < 12) {
57
52
  process.emitWarning('You are using a version of Node.js that will reach EOL in April 2021. ' +
@@ -184,16 +179,13 @@ class Client extends ESAPI {
184
179
  context: options.context
185
180
  })
186
181
 
187
- /* istanbul ignore else */
188
- if (Helpers !== null) {
189
- this.helpers = new Helpers({
190
- client: this,
191
- maxRetries: options.maxRetries,
192
- metaHeader: options.enableMetaHeader
193
- ? `es=${clientVersion},js=${nodeVersion},t=${clientVersion},hc=${nodeVersion}`
194
- : null
195
- })
196
- }
182
+ this.helpers = new Helpers({
183
+ client: this,
184
+ maxRetries: options.maxRetries,
185
+ metaHeader: options.enableMetaHeader
186
+ ? `es=${clientVersion},js=${nodeVersion},t=${clientVersion},hc=${nodeVersion}`
187
+ : null
188
+ })
197
189
  }
198
190
 
199
191
  get emit () {
@@ -218,7 +210,7 @@ class Client extends ESAPI {
218
210
  opts = {}
219
211
  }
220
212
 
221
- var [namespace, method] = name.split('.')
213
+ let [namespace, method] = name.split('.')
222
214
  if (method == null) {
223
215
  method = namespace
224
216
  namespace = null
package/lib/Connection.js CHANGED
@@ -213,8 +213,8 @@ class Connection {
213
213
  }
214
214
 
215
215
  const paramsKeys = Object.keys(params)
216
- for (var i = 0, len = paramsKeys.length; i < len; i++) {
217
- var key = paramsKeys[i]
216
+ for (let i = 0, len = paramsKeys.length; i < len; i++) {
217
+ const key = paramsKeys[i]
218
218
  if (key === 'path') {
219
219
  request.pathname = resolve(request.pathname, params[key])
220
220
  } else if (key === 'querystring' && !!params[key] === true) {
package/lib/Helpers.d.ts CHANGED
@@ -25,8 +25,8 @@ export default class Helpers {
25
25
  search<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(params: Search<TRequestBody>, options?: TransportRequestOptions): Promise<TDocument[]>
26
26
  scrollSearch<TDocument = unknown, TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: Search<TRequestBody>, options?: TransportRequestOptions): AsyncIterable<ScrollSearchResponse<TDocument, TResponse, TContext>>
27
27
  scrollDocuments<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(params: Search<TRequestBody>, options?: TransportRequestOptions): AsyncIterable<TDocument>
28
- msearch(options?: MsearchHelperOptions): MsearchHelper
29
- bulk<TDocument = unknown>(options: BulkHelperOptions<TDocument>): BulkHelper<BulkStats>
28
+ msearch(options?: MsearchHelperOptions, reqOptions?: TransportRequestOptions): MsearchHelper
29
+ bulk<TDocument = unknown>(options: BulkHelperOptions<TDocument>, reqOptions?: TransportRequestOptions): BulkHelper<BulkStats>
30
30
  }
31
31
 
32
32
  export interface ScrollSearchResponse<TDocument = unknown, TResponse = Record<string, any>, TContext = Context> extends ApiResponse<TResponse, TContext> {
package/lib/Helpers.js CHANGED
@@ -158,7 +158,7 @@ class Helpers {
158
158
  */
159
159
  async * scrollDocuments (params, options) {
160
160
  appendFilterPath('hits.hits._source', params, true)
161
- for await (const { documents } of this.scrollSearch(params)) {
161
+ for await (const { documents } of this.scrollSearch(params, options)) {
162
162
  for (const document of documents) {
163
163
  yield document
164
164
  }
@@ -169,9 +169,10 @@ class Helpers {
169
169
  * Creates a msearch helper instance. Once you configure it, you can use the provided
170
170
  * `search` method to add new searches in the queue.
171
171
  * @param {object} options - The configuration of the msearch operations.
172
+ * @param {object} reqOptions - The client optional configuration for this request.
172
173
  * @return {object} The possible operations to run.
173
174
  */
174
- msearch (options = {}) {
175
+ msearch (options = {}, reqOptions = {}) {
175
176
  const client = this[kClient]
176
177
  const {
177
178
  operations = 5,
@@ -378,7 +379,7 @@ class Helpers {
378
379
  // This function never returns an error, if the msearch operation fails,
379
380
  // the error is dispatched to all search executors.
380
381
  function tryMsearch (msearchBody, callbacks, done) {
381
- client.msearch(Object.assign({}, msearchOptions, { body: msearchBody }), (err, results) => {
382
+ client.msearch(Object.assign({}, msearchOptions, { body: msearchBody }), reqOptions, (err, results) => {
382
383
  const retryBody = []
383
384
  const retryCallbacks = []
384
385
  if (err) {
@@ -415,12 +416,16 @@ class Helpers {
415
416
  * Creates a bulk helper instance. Once you configure it, you can pick which operation
416
417
  * to execute with the given dataset, index, create, update, and delete.
417
418
  * @param {object} options - The configuration of the bulk operation.
419
+ * @param {object} reqOptions - The client optional configuration for this request.
418
420
  * @return {object} The possible operations to run with the datasource.
419
421
  */
420
- bulk (options) {
422
+ bulk (options, reqOptions = {}) {
421
423
  const client = this[kClient]
422
424
  const { serialize, deserialize } = client.serializer
423
- const reqOptions = this[kMetaHeader] !== null ? { headers: { 'x-elastic-client-meta': this[kMetaHeader] + ',h=bp' } } : {}
425
+ if (this[kMetaHeader] !== null) {
426
+ reqOptions.headers = reqOptions.headers || {}
427
+ reqOptions.headers['x-elastic-client-meta'] = this[kMetaHeader] + ',h=bp'
428
+ }
424
429
  const {
425
430
  datasource,
426
431
  onDocument,
@@ -545,7 +550,7 @@ class Helpers {
545
550
  index: typeof refreshOnCompletion === 'string'
546
551
  ? refreshOnCompletion
547
552
  : '_all'
548
- })
553
+ }, reqOptions)
549
554
  }
550
555
 
551
556
  stats.time = Date.now() - startTime
package/lib/Serializer.js CHANGED
@@ -27,8 +27,9 @@ const { SerializationError, DeserializationError } = require('./errors')
27
27
  class Serializer {
28
28
  serialize (object) {
29
29
  debug('Serializing', object)
30
+ let json
30
31
  try {
31
- var json = JSON.stringify(object)
32
+ json = JSON.stringify(object)
32
33
  } catch (err) {
33
34
  throw new SerializationError(err.message, object)
34
35
  }
@@ -37,8 +38,9 @@ class Serializer {
37
38
 
38
39
  deserialize (json) {
39
40
  debug('Deserializing', json)
41
+ let object
40
42
  try {
41
- var object = sjson.parse(json)
43
+ object = sjson.parse(json)
42
44
  } catch (err) {
43
45
  throw new DeserializationError(err.message, json)
44
46
  }
@@ -50,8 +52,8 @@ class Serializer {
50
52
  if (Array.isArray(array) === false) {
51
53
  throw new SerializationError('The argument provided is not an array')
52
54
  }
53
- var ndjson = ''
54
- for (var i = 0, len = array.length; i < len; i++) {
55
+ let ndjson = ''
56
+ for (let i = 0, len = array.length; i < len; i++) {
55
57
  if (typeof array[i] === 'string') {
56
58
  ndjson += array[i] + '\n'
57
59
  } else {
@@ -67,8 +69,8 @@ class Serializer {
67
69
  if (typeof object === 'string') return object
68
70
  // arrays should be serialized as comma separated list
69
71
  const keys = Object.keys(object)
70
- for (var i = 0, len = keys.length; i < len; i++) {
71
- var key = keys[i]
72
+ for (let i = 0, len = keys.length; i < len; i++) {
73
+ const key = keys[i]
72
74
  // elasticsearch will complain for keys without a value
73
75
  if (object[key] === undefined) {
74
76
  delete object[key]
@@ -120,6 +120,7 @@ export interface TransportRequestCallback {
120
120
 
121
121
  export interface TransportRequestPromise<T> extends Promise<T> {
122
122
  abort: () => void;
123
+ finally(onFinally?: (() => void) | undefined | null): Promise<T>;
123
124
  }
124
125
 
125
126
  export interface TransportGetConnectionOptions {
package/lib/Transport.js CHANGED
@@ -91,7 +91,7 @@ class Transport {
91
91
  callback = options
92
92
  options = {}
93
93
  }
94
- var p = null
94
+ let p = null
95
95
 
96
96
  // promises support
97
97
  if (callback === undefined) {
@@ -147,9 +147,10 @@ class Transport {
147
147
  // the size of the stream, we risk to take too much memory.
148
148
  // Furthermore, copying everytime the stream is very a expensive operation.
149
149
  const maxRetries = isStream(params.body) || isStream(params.bulkBody)
150
- ? 0 : (typeof options.maxRetries === 'number' ? options.maxRetries : this.maxRetries)
150
+ ? 0
151
+ : (typeof options.maxRetries === 'number' ? options.maxRetries : this.maxRetries)
151
152
  const compression = options.compression !== undefined ? options.compression : this.compression
152
- var request = { abort: noop }
153
+ let request = { abort: noop }
153
154
  const transportReturn = {
154
155
  then (onFulfilled, onRejected) {
155
156
  return p.then(onFulfilled, onRejected)
@@ -162,6 +163,9 @@ class Transport {
162
163
  request.abort()
163
164
  debug('Aborting request', params)
164
165
  return this
166
+ },
167
+ finally (onFinally) {
168
+ return p.finally(onFinally)
165
169
  }
166
170
  }
167
171
 
@@ -525,7 +529,7 @@ function defaultNodeFilter (node) {
525
529
  }
526
530
 
527
531
  function roundRobinSelector () {
528
- var current = -1
532
+ let current = -1
529
533
  return function _roundRobinSelector (connections) {
530
534
  if (++current >= connections.length) {
531
535
  current = 0
@@ -540,8 +544,8 @@ function randomSelector (connections) {
540
544
  }
541
545
 
542
546
  function generateRequestId () {
543
- var maxInt = 2147483647
544
- var nextReqId = 0
547
+ const maxInt = 2147483647
548
+ let nextReqId = 0
545
549
  return function genReqId (params, options) {
546
550
  return (nextReqId = (nextReqId + 1) & maxInt)
547
551
  }
@@ -128,7 +128,7 @@ class BaseConnectionPool {
128
128
  */
129
129
  empty (callback) {
130
130
  debug('Emptying the connection pool')
131
- var openConnections = this.size
131
+ let openConnections = this.size
132
132
  this.connections.forEach(connection => {
133
133
  connection.close(() => {
134
134
  if (--openConnections === 0) {
@@ -201,7 +201,7 @@ class BaseConnectionPool {
201
201
  const ids = Object.keys(nodes)
202
202
  const hosts = []
203
203
 
204
- for (var i = 0, len = ids.length; i < len; i++) {
204
+ for (let i = 0, len = ids.length; i < len; i++) {
205
205
  const node = nodes[ids[i]]
206
206
  // If there is no protocol in
207
207
  // the `publish_address` new URL will throw
@@ -210,7 +210,7 @@ class BaseConnectionPool {
210
210
  // - hostname/ip:port
211
211
  // if we encounter the second case, we should
212
212
  // use the hostname instead of the ip
213
- var address = node.http.publish_address
213
+ let address = node.http.publish_address
214
214
  const parts = address.split('/')
215
215
  // the url is in the form of hostname/ip:port
216
216
  if (parts.length > 1) {
@@ -80,7 +80,7 @@ class ConnectionPool extends BaseConnectionPool {
80
80
  // list a node that no longer exist. The following check verify
81
81
  // that the connection is still part of the pool before
82
82
  // marking it as dead.
83
- for (var i = 0; i < this.size; i++) {
83
+ for (let i = 0; i < this.size; i++) {
84
84
  if (this.connections[i].id === id) {
85
85
  this.dead.push(id)
86
86
  break
@@ -138,7 +138,7 @@ class ConnectionPool extends BaseConnectionPool {
138
138
  path: '/',
139
139
  timeout: this.pingTimeout
140
140
  }, (err, response) => {
141
- var isAlive = true
141
+ let isAlive = true
142
142
  const statusCode = response !== null ? response.statusCode : 0
143
143
  if (err != null ||
144
144
  (statusCode === 502 || statusCode === 503 || statusCode === 504)) {
@@ -170,8 +170,7 @@ class ConnectionPool extends BaseConnectionPool {
170
170
  isAlive: true,
171
171
  connection
172
172
  })
173
- // eslint-disable-next-line standard/no-callback-literal
174
- callback(true, connection)
173
+ callback(true, connection) // eslint-disable-line
175
174
  }
176
175
  }
177
176
 
@@ -199,7 +198,7 @@ class ConnectionPool extends BaseConnectionPool {
199
198
 
200
199
  // TODO: can we cache this?
201
200
  const connections = []
202
- for (var i = 0; i < this.size; i++) {
201
+ for (let i = 0; i < this.size; i++) {
203
202
  const connection = this.connections[i]
204
203
  if (noAliveConnections || connection.status === Connection.statuses.ALIVE) {
205
204
  if (filter(connection) === true) {