Skip to content

Commit

Permalink
[Maps] use source fields instead of terms fields for left source fiel…
Browse files Browse the repository at this point in the history
…ds (#44386)
  • Loading branch information
nreese authored Sep 3, 2019
1 parent 8b4971b commit 5854d9e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 8 additions & 0 deletions x-pack/legacy/plugins/maps/public/index_pattern_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ export function getTermsFields(fields) {
return field.aggregatable && ['number', 'boolean', 'date', 'ip', 'string'].includes(field.type);
});
}

// Returns filtered fields list containing only fields that exist in _source.
export function getSourceFields(fields) {
return fields.filter(field => {
// Multi fields are not stored in _source and only exist in index.
return field.subType !== 'multi';
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ES_SEARCH, ES_GEO_FIELD_TYPE, ES_SIZE_LIMIT } from '../../../../common/
import { i18n } from '@kbn/i18n';
import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { ESTooltipProperty } from '../../tooltips/es_tooltip_property';
import { getTermsFields } from '../../../index_pattern_util';
import { getSourceFields } from '../../../index_pattern_util';

import { DEFAULT_FILTER_BY_MAP_BOUNDS } from './constants';

Expand Down Expand Up @@ -325,7 +325,8 @@ export class ESSearchSource extends AbstractESSource {

async getLeftJoinFields() {
const indexPattern = await this._getIndexPattern();
return getTermsFields(indexPattern.fields)
// Left fields are retrieved from _source.
return getSourceFields(indexPattern.fields)
.map(field => {
return { name: field.name, label: field.name };
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TooltipSelector } from '../../../components/tooltip_selector';

import { indexPatternService } from '../../../kibana_services';
import { i18n } from '@kbn/i18n';
import { getTermsFields } from '../../../index_pattern_util';
import { getTermsFields, getSourceFields } from '../../../index_pattern_util';
import { ValidatedRange } from '../../../components/validated_range';

export class UpdateSourceEditor extends Component {
Expand Down Expand Up @@ -74,11 +74,7 @@ export class UpdateSourceEditor extends Component {

this.setState({
dateFields,
tooltipFields: indexPattern.fields.filter(field => {
// Do not show multi fields as tooltip field options
// since they do not have values in _source and exist for indexing only
return field.subType !== 'multi';
}),
tooltipFields: getSourceFields(indexPattern.fields),
termFields: getTermsFields(indexPattern.fields),
});

Expand Down

0 comments on commit 5854d9e

Please sign in to comment.