mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Maps] set filter.meta.key to geoFieldName so query passes filterMatchesIndex when ignoreFilterIfFieldNotInIndex is true (#56692) (#57250)
* [Maps] set filter.meta.key to geoFieldName so query passes filterMatchesIndex * remove unused variable Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
530d8c25ec
commit
1de83bd387
3 changed files with 8 additions and 8 deletions
|
@ -24,6 +24,7 @@ describe('mapSpatialFilter()', () => {
|
|||
test('should return the key for matching multi polygon filter', async () => {
|
||||
const filter = {
|
||||
meta: {
|
||||
key: 'location',
|
||||
alias: 'my spatial filter',
|
||||
type: esFilters.FILTERS.SPATIAL_FILTER,
|
||||
} as esFilters.FilterMeta,
|
||||
|
@ -41,7 +42,7 @@ describe('mapSpatialFilter()', () => {
|
|||
} as esFilters.Filter;
|
||||
const result = mapSpatialFilter(filter);
|
||||
|
||||
expect(result).toHaveProperty('key', 'query');
|
||||
expect(result).toHaveProperty('key', 'location');
|
||||
expect(result).toHaveProperty('value', '');
|
||||
expect(result).toHaveProperty('type', esFilters.FILTERS.SPATIAL_FILTER);
|
||||
});
|
||||
|
@ -49,6 +50,7 @@ describe('mapSpatialFilter()', () => {
|
|||
test('should return the key for matching polygon filter', async () => {
|
||||
const filter = {
|
||||
meta: {
|
||||
key: 'location',
|
||||
alias: 'my spatial filter',
|
||||
type: esFilters.FILTERS.SPATIAL_FILTER,
|
||||
} as esFilters.FilterMeta,
|
||||
|
@ -58,7 +60,7 @@ describe('mapSpatialFilter()', () => {
|
|||
} as esFilters.Filter;
|
||||
const result = mapSpatialFilter(filter);
|
||||
|
||||
expect(result).toHaveProperty('key', 'geo_polygon');
|
||||
expect(result).toHaveProperty('key', 'location');
|
||||
expect(result).toHaveProperty('value', '');
|
||||
expect(result).toHaveProperty('type', esFilters.FILTERS.SPATIAL_FILTER);
|
||||
});
|
||||
|
@ -66,6 +68,7 @@ describe('mapSpatialFilter()', () => {
|
|||
test('should return undefined for none matching', async done => {
|
||||
const filter = {
|
||||
meta: {
|
||||
key: 'location',
|
||||
alias: 'my spatial filter',
|
||||
} as esFilters.FilterMeta,
|
||||
geo_polygon: {
|
||||
|
|
|
@ -20,18 +20,14 @@ import { esFilters } from '../../../../../common';
|
|||
|
||||
// Use mapSpatialFilter mapper to avoid bloated meta with value and params for spatial filters.
|
||||
export const mapSpatialFilter = (filter: esFilters.Filter) => {
|
||||
const metaProperty = /(^\$|meta)/;
|
||||
const key = Object.keys(filter).find(item => {
|
||||
return !item.match(metaProperty);
|
||||
});
|
||||
if (
|
||||
key &&
|
||||
filter.meta &&
|
||||
filter.meta.key &&
|
||||
filter.meta.alias &&
|
||||
filter.meta.type === esFilters.FILTERS.SPATIAL_FILTER
|
||||
) {
|
||||
return {
|
||||
key,
|
||||
key: filter.meta.key,
|
||||
type: filter.meta.type,
|
||||
value: '',
|
||||
};
|
||||
|
|
|
@ -297,6 +297,7 @@ function createGeometryFilterWithMeta({
|
|||
type: SPATIAL_FILTER_TYPE,
|
||||
negate: false,
|
||||
index: indexPatternId,
|
||||
key: geoFieldName,
|
||||
alias: `${geoFieldName} ${relationLabel} ${geometryLabel}`,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue