Skip to content

Commit

Permalink
[Search Source] Specify strict_date_optional_time_nanos as a formatte…
Browse files Browse the repository at this point in the history
…r for date_nanos field
  • Loading branch information
Maja Grubic committed Feb 5, 2021
1 parent f329ff8 commit 8e9911e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class IndexPattern implements IIndexPattern {
field: dateField.name,
format:
dateField.esTypes && dateField.esTypes.indexOf('date_nanos') !== -1
? 'strict_date_time'
? 'strict_date_optional_time_nanos'
: 'date_time',
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/data/common/search/search_source/search_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ export class SearchSource {
// if items that are in the docvalueFields are provided, we should
// inject the format from the computed fields if one isn't given
const docvaluesIndex = keyBy(filteredDocvalueFields, 'field');
const formatterIndex = keyBy(filteredDocvalueFields, 'format');
body.fields = body.fields.map((fld: SearchFieldValue) => {
const fieldName = getFieldName(fld);
if (Object.keys(docvaluesIndex).includes(fieldName)) {
Expand All @@ -626,6 +627,10 @@ export class SearchSource {
...fld,
};
}
if (Object.keys(formatterIndex).includes('strict_date_optional_time_nanos')) {
// @ts-ignore
fld.format = 'strict_date_optional_time_nanos';
}
return fld;
});
}
Expand Down

0 comments on commit 8e9911e

Please sign in to comment.