node-es-transformer 1.0.0-alpha8 → 1.0.0-alpha9

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/README.md CHANGED
@@ -46,20 +46,18 @@ transformer({
46
46
  fileName: 'filename.json',
47
47
  targetIndexName: 'my-index',
48
48
  mappings: {
49
- _doc: {
50
- properties: {
51
- '@timestamp': {
52
- type: 'date'
53
- },
54
- 'first_name': {
55
- type: 'keyword'
56
- },
57
- 'last_name': {
58
- type: 'keyword'
59
- }
60
- 'full_name': {
61
- type: 'keyword'
62
- }
49
+ properties: {
50
+ '@timestamp': {
51
+ type: 'date'
52
+ },
53
+ 'first_name': {
54
+ type: 'keyword'
55
+ },
56
+ 'last_name': {
57
+ type: 'keyword'
58
+ }
59
+ 'full_name': {
60
+ type: 'keyword'
63
61
  }
64
62
  }
65
63
  },
@@ -82,20 +80,18 @@ transformer({
82
80
  targetIndexName: 'my-target-index',
83
81
  // optional, if you skip mappings, they will be fetched from the source index.
84
82
  mappings: {
85
- _doc: {
86
- properties: {
87
- '@timestamp': {
88
- type: 'date'
89
- },
90
- 'first_name': {
91
- type: 'keyword'
92
- },
93
- 'last_name': {
94
- type: 'keyword'
95
- }
96
- 'full_name': {
97
- type: 'keyword'
98
- }
83
+ properties: {
84
+ '@timestamp': {
85
+ type: 'date'
86
+ },
87
+ 'first_name': {
88
+ type: 'keyword'
89
+ },
90
+ 'last_name': {
91
+ type: 'keyword'
92
+ }
93
+ 'full_name': {
94
+ type: 'keyword'
99
95
  }
100
96
  }
101
97
  },
@@ -111,16 +107,11 @@ transformer({
111
107
  ### Options
112
108
 
113
109
  - `deleteIndex`: Setting to automatically delete an existing index, default is `false`.
114
- - `protocol`/`targetProtocol`: Elasticsearch protocol, defaults to `http`.
115
- - `host`/`targetHost`: Elasticsearch host, defaults to `localhost`.
116
- - `port`/`targetPort`: Elasticsearch port, defaults to `9200`.
117
- - `auth`/`targetAuth`: Optional Elasticsearch authorization object, for example `{ username: 'elastic', password: 'changeme'}`.
118
- - `rejectUnauthorized`: Elasticsearch TLS option, defaults to `true`.
119
- - `ca`: Optional path to certificate used for TLS configuraiton.
110
+ - `sourceClientConfig`/`targetClientConfig`: Optional Elasticsearch client options, defaults to `{ node: 'http://localhost:9200' }`.
120
111
  - `bufferSize`: The amount of documents inserted with each Elasticsearch bulk insert request, default is `1000`.
121
112
  - `fileName`: Source filename to ingest, supports wildcards. If this is set, `sourceIndexName` is not allowed.
122
113
  - `splitRegex`: Custom line split regex, defaults to `/\n/`.
123
- - `sourceIndexName`: The source Elasticsearch to reindex from. If this is set, `fileName` is not allowed.
114
+ - `sourceIndexName`: The source Elasticsearch index to reindex from. If this is set, `fileName` is not allowed.
124
115
  - `targetIndexName`: The target Elasticsearch index where documents will be indexed.
125
116
  - `mappings`: Elasticsearch document mapping.
126
117
  - `skipHeader`: If true, skips the first line of the source file. Defaults to `false`.
@@ -286,16 +286,8 @@ function indexReaderFactory(indexer, sourceIndexName, transform, client) {
286
286
 
287
287
  async function transformer(ref) {
288
288
  var deleteIndex = ref.deleteIndex; if ( deleteIndex === void 0 ) deleteIndex = false;
289
- var protocol = ref.protocol; if ( protocol === void 0 ) protocol = 'http';
290
- var host = ref.host; if ( host === void 0 ) host = 'localhost';
291
- var port = ref.port; if ( port === void 0 ) port = '9200';
292
- var auth = ref.auth;
293
- var rejectUnauthorized = ref.rejectUnauthorized; if ( rejectUnauthorized === void 0 ) rejectUnauthorized = true;
294
- var ca = ref.ca;
295
- var targetProtocol = ref.targetProtocol;
296
- var targetHost = ref.targetHost;
297
- var targetPort = ref.targetPort;
298
- var targetAuth = ref.targetAuth;
289
+ var sourceClientConfig = ref.sourceClientConfig;
290
+ var targetClientConfig = ref.targetClientConfig;
299
291
  var bufferSize = ref.bufferSize; if ( bufferSize === void 0 ) bufferSize = 1000;
300
292
  var fileName = ref.fileName;
301
293
  var splitRegex = ref.splitRegex; if ( splitRegex === void 0 ) splitRegex = /\n/;
@@ -310,19 +302,14 @@ async function transformer(ref) {
310
302
  throw Error('targetIndexName must be specified.');
311
303
  }
312
304
 
313
- var sourceNode = protocol + "://" + host + ":" + port;
314
- var sourceClient = new elasticsearch.Client({
315
- node: sourceNode,
316
- auth: auth,
317
- tls: { ca: ca, rejectUnauthorized: rejectUnauthorized },
318
- });
305
+ var defaultClientConfig = {
306
+ node: 'http://localhost:9200',
307
+ };
319
308
 
320
- var targetNode = (typeof targetProtocol === 'string' ? targetProtocol : protocol) + "://" + (typeof targetHost === 'string' ? targetHost : host) + ":" + (typeof targetPort === 'string' ? targetPort : port);
321
- var targetClient = new elasticsearch.Client({
322
- node: targetNode,
323
- auth: targetAuth !== undefined ? targetAuth : auth,
324
- tls: { ca: ca, rejectUnauthorized: rejectUnauthorized },
325
- });
309
+ var sourceClient = new elasticsearch.Client(sourceClientConfig || defaultClientConfig);
310
+ var targetClient = new elasticsearch.Client(
311
+ targetClientConfig || sourceClientConfig || defaultClientConfig
312
+ );
326
313
 
327
314
  var createMapping = createMappingFactory({
328
315
  sourceClient: sourceClient,
@@ -282,16 +282,8 @@ function indexReaderFactory(indexer, sourceIndexName, transform, client) {
282
282
 
283
283
  async function transformer(ref) {
284
284
  var deleteIndex = ref.deleteIndex; if ( deleteIndex === void 0 ) deleteIndex = false;
285
- var protocol = ref.protocol; if ( protocol === void 0 ) protocol = 'http';
286
- var host = ref.host; if ( host === void 0 ) host = 'localhost';
287
- var port = ref.port; if ( port === void 0 ) port = '9200';
288
- var auth = ref.auth;
289
- var rejectUnauthorized = ref.rejectUnauthorized; if ( rejectUnauthorized === void 0 ) rejectUnauthorized = true;
290
- var ca = ref.ca;
291
- var targetProtocol = ref.targetProtocol;
292
- var targetHost = ref.targetHost;
293
- var targetPort = ref.targetPort;
294
- var targetAuth = ref.targetAuth;
285
+ var sourceClientConfig = ref.sourceClientConfig;
286
+ var targetClientConfig = ref.targetClientConfig;
295
287
  var bufferSize = ref.bufferSize; if ( bufferSize === void 0 ) bufferSize = 1000;
296
288
  var fileName = ref.fileName;
297
289
  var splitRegex = ref.splitRegex; if ( splitRegex === void 0 ) splitRegex = /\n/;
@@ -306,19 +298,14 @@ async function transformer(ref) {
306
298
  throw Error('targetIndexName must be specified.');
307
299
  }
308
300
 
309
- var sourceNode = protocol + "://" + host + ":" + port;
310
- var sourceClient = new elasticsearch.Client({
311
- node: sourceNode,
312
- auth: auth,
313
- tls: { ca: ca, rejectUnauthorized: rejectUnauthorized },
314
- });
301
+ var defaultClientConfig = {
302
+ node: 'http://localhost:9200',
303
+ };
315
304
 
316
- var targetNode = (typeof targetProtocol === 'string' ? targetProtocol : protocol) + "://" + (typeof targetHost === 'string' ? targetHost : host) + ":" + (typeof targetPort === 'string' ? targetPort : port);
317
- var targetClient = new elasticsearch.Client({
318
- node: targetNode,
319
- auth: targetAuth !== undefined ? targetAuth : auth,
320
- tls: { ca: ca, rejectUnauthorized: rejectUnauthorized },
321
- });
305
+ var sourceClient = new elasticsearch.Client(sourceClientConfig || defaultClientConfig);
306
+ var targetClient = new elasticsearch.Client(
307
+ targetClientConfig || sourceClientConfig || defaultClientConfig
308
+ );
322
309
 
323
310
  var createMapping = createMappingFactory({
324
311
  sourceClient: sourceClient,
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "license": "Apache-2.0",
15
15
  "author": "Walter Rafelsberger <walter@rafelsberger.at>",
16
16
  "contributors": [],
17
- "version": "1.0.0-alpha8",
17
+ "version": "1.0.0-alpha9",
18
18
  "main": "dist/node-es-transformer.cjs.js",
19
19
  "module": "dist/node-es-transformer.esm.js",
20
20
  "dependencies": {