Skip to content

Commit

Permalink
index @timesstamp field added
Browse files Browse the repository at this point in the history
  • Loading branch information
vsboldakov committed Sep 13, 2019
1 parent 47e73fc commit bbec36f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sink/ElasticSinkConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ElasticSinkConnector extends SinkConnector {
index: this.properties.restSink.index,
type: this.properties.restSink.type,
mode: this.properties.restSink.mode,
indexTimestampFieldName: this.properties.restSink.indexTimestampFieldName,
};

callback(null, taskConfig);
Expand Down
5 changes: 5 additions & 0 deletions lib/sink/ElasticSinkTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class ElasticSinkTask extends SinkTask {
index,
type,
batchSize,
indexTimestampFieldName,
} = this.properties;

this.esClient = esClient;
this.idProperty = idProperty;
this.index = index;
this.type = type;
this.batchSize = batchSize;
this.indexTimestampFieldName = indexTimestampFieldName;

this.upserts = new Map();
this.deletes = new Set();
Expand Down Expand Up @@ -57,6 +59,9 @@ class ElasticSinkTask extends SinkTask {
let id = record[this.idProperty];
body.push({ "update": {"_id": id, "_index": this.index}});
delete record[this.idProperty];
if (this.indexTimestampFieldName && record.doc) {
record.doc[this.indexTimestampFieldName] = (new Date()).getTime();
}
body.push(record);
}
}
Expand Down

0 comments on commit bbec36f

Please sign in to comment.