[Maps] use source fields instead of terms fields for left source fields (#44386) (#44691)

This commit is contained in:
Nathan Reese 2019-09-03 18:23:53 -06:00 committed by GitHub
parent 207c773f21
commit 5ff09e72c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View file

@ -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';
});
}

View file

@ -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';
@ -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 };
});

View file

@ -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 {
@ -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),
});