We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 729f9ba commit 9381f92Copy full SHA for 9381f92
handlers/shipElasticsearch.js
@@ -43,9 +43,22 @@ exports.process = function(config) {
43
};
44
45
_.forEach(config.data, function(datum) {
46
+
47
+ var indexName = config.elasticsearch.index;
48
49
+ // if date is available, build dynamic index: [index]-YYYY.MM.DD
50
+ if (config.dateField) {
51
+ var timestamp = new Date(datum[config.dateField]);
52
+ indexName = [
53
+ indexName + '-' + timestamp.getUTCFullYear(), // year
54
+ ('0' + (timestamp.getUTCMonth() + 1)).slice(-2), // month
55
+ ('0' + timestamp.getUTCDate()).slice(-2) // day
56
+ ].join('.');
57
+ }
58
59
docs.push({
60
index: {
- _index: config.elasticsearch.index,
61
+ _index: indexName,
62
_type: config.elasticsearch.type
63
}
64
});
0 commit comments