Skip to content

Commit aec93cb

Browse files
committed
Retrieve only epoch_millis for date fields in docvalues
1 parent c44fa85 commit aec93cb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

x-pack/legacy/plugins/maps/public/layers/sources/es_search_source/es_search_source.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ export class ESSearchSource extends AbstractESSource {
163163
];
164164
}
165165

166+
async _getFieldsExcludingTimeFields(fieldNames) {
167+
const timeFieldNames = _.map(await this.getTimeFields(), 'name');
168+
return fieldNames.filter(field => {
169+
return !timeFieldNames.includes(field);
170+
});
171+
}
172+
166173
async _getTopHits(layerName, searchFilters, registerCancelCallback) {
167174
const {
168175
topHitsSplitField,
@@ -192,6 +199,8 @@ export class ESSearchSource extends AbstractESSource {
192199
docvalue_fields: [],
193200
};
194201

202+
const fieldNames = await this._getFieldsExcludingTimeFields(searchFilters.fieldNames);
203+
195204
timeFields.forEach(field => {
196205
topHits.docvalue_fields.push({
197206
field: field.name,
@@ -203,7 +212,7 @@ export class ESSearchSource extends AbstractESSource {
203212
}
204213
if (geoField.type === ES_GEO_FIELD_TYPE.GEO_POINT) {
205214
topHits._source = false;
206-
topHits.docvalue_fields.push(...searchFilters.fieldNames);
215+
topHits.docvalue_fields.push(...fieldNames);
207216
} else {
208217
topHits._source = {
209218
includes: searchFilters.fieldNames
@@ -257,6 +266,7 @@ export class ESSearchSource extends AbstractESSource {
257266
};
258267
const geoField = await this._getGeoField();
259268
const timeFields = await this.getTimeFields();
269+
const fieldNames = await this._getFieldsExcludingTimeFields(searchFilters.fieldNames);
260270
timeFields.forEach(field => {
261271
initialSearchContext.docvalue_fields.push({
262272
field: field.name,
@@ -269,7 +279,7 @@ export class ESSearchSource extends AbstractESSource {
269279
// Request geo_point and style fields in docvalue_fields insted of _source
270280
// 1) Returns geo_point in a consistent format regardless of how geo_point is stored in source
271281
// 2) Setting _source to false so we avoid pulling back unneeded fields.
272-
initialSearchContext.docvalue_fields.push(...searchFilters.fieldNames);
282+
initialSearchContext.docvalue_fields.push(...fieldNames);
273283
searchSource = await this._makeSearchSource(searchFilters, ES_SIZE_LIMIT, initialSearchContext);
274284
searchSource.setField('source', false); // do not need anything from _source
275285
searchSource.setField('fields', searchFilters.fieldNames); // Setting "fields" filters out unused scripted fields

x-pack/legacy/plugins/maps/public/layers/styles/vector_style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export class VectorStyle extends AbstractStyle {
394394

395395
for (let j = 0; j < styleFields.length; j++) {
396396
const { supportsFeatureState, isScaled, name, range, computedName } = styleFields[j];
397-
//Date fields pulled from doc_values is an array of epoch_millis and a date string
397+
//Date fields pulled from doc_values is an array
398398
const value = Array.isArray(feature.properties[name])
399399
? parseFloat(feature.properties[name][0])
400400
: parseFloat(feature.properties[name]);

0 commit comments

Comments
 (0)