Skip to content

Commit

Permalink
[Lens] Show keyword fields for pre-7.3 index patterns (#52410) (#52544)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wylie Conlon authored Dec 9, 2019
1 parent 249d634 commit 0bed743
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,19 @@ const sampleIndexPatterns = {
};

function indexPatternSavedObject({ id }: { id: keyof typeof sampleIndexPatterns }) {
const pattern = sampleIndexPatterns[id];
const pattern = {
...sampleIndexPatterns[id],
fields: [
...sampleIndexPatterns[id].fields,
{
name: 'description',
type: 'string',
aggregatable: false,
searchable: true,
esTypes: ['text'],
},
],
};
return {
id,
type: 'index-pattern',
Expand Down Expand Up @@ -184,6 +196,16 @@ describe('loader', () => {
expect(cache).toMatchObject(sampleIndexPatterns);
});

it('should not allow full text fields', async () => {
const cache = await loadIndexPatterns({
cache: {},
patterns: ['a', 'b'],
savedObjectsClient: mockClient(),
});

expect(cache).toMatchObject(sampleIndexPatterns);
});

it('should apply field restrictions from typeMeta', async () => {
const cache = await loadIndexPatterns({
cache: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,7 @@ function fromSavedObject(
type,
title: attributes.title,
fields: (JSON.parse(attributes.fields) as IndexPatternField[])
.filter(
({ type: fieldType, esTypes }) =>
fieldType !== 'string' || (esTypes && esTypes.includes('keyword'))
)
.filter(({ aggregatable }) => !!aggregatable)
.concat(documentField),
typeMeta: attributes.typeMeta
? (JSON.parse(attributes.typeMeta) as SavedRestrictionsInfo)
Expand Down

0 comments on commit 0bed743

Please sign in to comment.