Update sample date scripts to use more efficient scripts
This commit is contained in:
parent
093e7a22fa
commit
72d8087225
|
@ -2,28 +2,25 @@ define(function (require) {
|
|||
var _ = require('lodash');
|
||||
|
||||
return function (indexPattern) {
|
||||
|
||||
|
||||
function getScript(field, format) {
|
||||
return 'Integer.parseInt(new Date(doc["' + field + '"].value).format("' + format + '"))';
|
||||
}
|
||||
|
||||
var dateScripts = {};
|
||||
var scripts = {
|
||||
__minuteOfHour: 'm',
|
||||
__hourOfDay: 'H',
|
||||
__dayOfWeek: 'u',
|
||||
__dayOfMonth: 'd',
|
||||
__dayOfYear: 'D',
|
||||
__weekOfMonth: 'W',
|
||||
__weekOfYear: 'w',
|
||||
__monthOfYear: 'M'
|
||||
};
|
||||
var scripts = [
|
||||
'dayOfMonth',
|
||||
'dayOfWeek',
|
||||
'dayOfYear',
|
||||
'hourOfDay',
|
||||
'minuteOfDay',
|
||||
'minuteOfHour',
|
||||
'minuteOfHour',
|
||||
'monthOfYear',
|
||||
'weekOfWeekyear',
|
||||
'weekyear',
|
||||
'year'
|
||||
];
|
||||
|
||||
_.each(indexPattern.fields.byType['date'], function (field) {
|
||||
if (field.indexed) {
|
||||
_.each(scripts, function (format, scriptKey) {
|
||||
dateScripts[field.name + '.' + scriptKey] = getScript(field.name, format);
|
||||
scripts.forEach(function (script) {
|
||||
dateScripts[field.name + '.__' + script] = 'doc["' + field.name + '"].date.' + script;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue