Skip to content

Commit

Permalink
[Maps] filtered out docs with empty entity ids for tracks and top-hit…
Browse files Browse the repository at this point in the history
…s layers (elastic#107680) (elastic#108100)

* [Maps] filtered out docs with empty entity ids for tracks and top-hits layers

* eslint

* add type check for string fields

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Nathan Reese <[email protected]>
  • Loading branch information
kibanamachine and nreese authored Aug 10, 2021
1 parent 00dc2ac commit 7bbf1bc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React from 'react';

import { GeoJsonProperties } from 'geojson';
import { i18n } from '@kbn/i18n';
import type { Filter } from 'src/plugins/data/public';
import {
EMPTY_FEATURE_COLLECTION,
FIELD_ORIGIN,
Expand Down Expand Up @@ -202,6 +203,15 @@ export class ESGeoLineSource extends AbstractESAggSource {
terms: addFieldToDSL(termsAgg, splitField),
},
});
if (splitField.type === 'string') {
const entityIsNotEmptyFilter = esFilters.buildPhraseFilter(splitField, '', indexPattern);
entityIsNotEmptyFilter.meta.negate = true;
entitySearchSource.setField('filter', [
...(entitySearchSource.getField('filter') as Filter[]),
entityIsNotEmptyFilter,
]);
}

const entityResp = await this._runEsQuery({
requestId: `${this.getId()}_entities`,
requestName: i18n.translate('xpack.maps.source.esGeoLine.entityRequestName', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import _ from 'lodash';
import React, { ReactElement } from 'react';
import rison from 'rison-node';
import { i18n } from '@kbn/i18n';
import { IFieldType, IndexPattern } from 'src/plugins/data/public';
import type { Filter, IFieldType, IndexPattern } from 'src/plugins/data/public';
import { GeoJsonProperties, Geometry, Position } from 'geojson';
import { esFilters } from '../../../../../../../src/plugins/data/public';
import { AbstractESSource } from '../es_source';
import { getHttp, getSearchService, getTimeFilter } from '../../../kibana_services';
import {
Expand Down Expand Up @@ -311,6 +312,18 @@ export class ESSearchSource extends AbstractESSource implements ITiledSingleLaye
},
},
});
if (topHitsSplitField.type === 'string') {
const entityIsNotEmptyFilter = esFilters.buildPhraseFilter(
topHitsSplitField,
'',
indexPattern
);
entityIsNotEmptyFilter.meta.negate = true;
searchSource.setField('filter', [
...(searchSource.getField('filter') as Filter[]),
entityIsNotEmptyFilter,
]);
}

const resp = await this._runEsQuery({
requestId: this.getId(),
Expand Down

0 comments on commit 7bbf1bc

Please sign in to comment.