Skip to content

Commit

Permalink
Sync old index_patters changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinar-24 committed Nov 25, 2019
1 parent cd283bb commit da1978f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
48 changes: 0 additions & 48 deletions src/plugins/data/public/index_patterns/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,9 @@ import {
CONTAINS_SPACES,
ILLEGAL_CHARACTERS,
INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE,
isFilterable,
validateIndexPattern,
} from './utils';

import { Field } from './fields';

const mockField = {
name: 'foo',
scripted: false,
searchable: true,
type: 'string',
} as Field;

describe('Index Pattern Utils', () => {
describe('Validation', () => {
it('should not allow space in the pattern', () => {
Expand All @@ -52,42 +42,4 @@ describe('Index Pattern Utils', () => {
expect(validateIndexPattern('my-pattern-*')).toEqual({});
});
});

describe('isFilterable', () => {
describe('types', () => {
it('should return true for filterable types', () => {
['string', 'number', 'date', 'ip', 'boolean'].forEach(type => {
expect(isFilterable({ ...mockField, type })).toBe(true);
});
});

it('should return false for filterable types if the field is not searchable', () => {
['string', 'number', 'date', 'ip', 'boolean'].forEach(type => {
expect(isFilterable({ ...mockField, type, searchable: false })).toBe(false);
});
});

it('should return false for un-filterable types', () => {
[
'geo_point',
'geo_shape',
'attachment',
'murmur3',
'_source',
'unknown',
'conflict',
].forEach(type => {
expect(isFilterable({ ...mockField, type })).toBe(false);
});
});
});

it('should return true for scripted fields', () => {
expect(isFilterable({ ...mockField, scripted: true, searchable: false })).toBe(true);
});

it('should return true for the _id field', () => {
expect(isFilterable({ ...mockField, name: '_id' })).toBe(true);
});
});
});
12 changes: 0 additions & 12 deletions src/plugins/data/public/index_patterns/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import { find, get } from 'lodash';
import { SavedObjectsClientContract, SimpleSavedObject } from 'src/core/public';
import { Field } from './fields';
import { getFilterableKbnTypeNames } from '../../common';

export const ILLEGAL_CHARACTERS = 'ILLEGAL_CHARACTERS';
export const CONTAINS_SPACES = 'CONTAINS_SPACES';
Expand Down Expand Up @@ -105,16 +103,6 @@ export function validateIndexPattern(indexPattern: string) {
return errors;
}

const filterableTypes = getFilterableKbnTypeNames();

export function isFilterable(field: Field): boolean {
return (
field.name === '_id' ||
field.scripted ||
Boolean(field.searchable && filterableTypes.includes(field.type))
);
}

export function getFromSavedObject(savedObject: any) {
if (get(savedObject, 'attributes.fields') === undefined) {
return;
Expand Down

0 comments on commit da1978f

Please sign in to comment.