Skip to content

Commit 44cd5a2

Browse files
committed
Adapt struct for convention, determine which fields not to index
1 parent dbd8cc5 commit 44cd5a2

5 files changed

Lines changed: 35 additions & 15 deletions

File tree

src/plugins/discover/server/plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
import { CoreSetup, CoreStart, Plugin } from 'kibana/server';
2121
import { uiSettings } from './ui_settings';
2222
import { capabilitiesProvider } from './capabilities_provider';
23-
import { searchSavedObjectType } from './search';
23+
import { search } from './saved_objects';
2424

2525
export class DiscoverServerPlugin implements Plugin<object, object> {
2626
public setup(core: CoreSetup) {
2727
core.capabilities.registerProvider(capabilitiesProvider);
2828
core.uiSettings.register(uiSettings);
29-
core.savedObjects.registerType(searchSavedObjectType);
29+
core.savedObjects.registerType(search);
3030

3131
return {};
3232
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
export { search } from './search';

src/plugins/discover/server/search.ts renamed to src/plugins/discover/server/saved_objects/search.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
*/
1919

2020
import { SavedObjectsType } from 'kibana/server';
21-
import { searchSavedObjectTypeMigrations } from './search_migrations';
21+
import { searchMigrations } from './search_migrations';
2222

23-
export const searchSavedObjectType: SavedObjectsType = {
23+
export const search: SavedObjectsType = {
2424
name: 'search',
2525
hidden: false,
2626
namespaceType: 'single',
@@ -43,18 +43,18 @@ export const searchSavedObjectType: SavedObjectsType = {
4343
},
4444
mappings: {
4545
properties: {
46-
columns: { type: 'keyword' },
46+
columns: { type: 'keyword', index: false },
4747
description: { type: 'text' },
48-
hits: { type: 'integer' },
48+
hits: { type: 'integer', index: false },
4949
kibanaSavedObjectMeta: {
5050
properties: {
51-
searchSourceJSON: { type: 'text' },
51+
searchSourceJSON: { type: 'text', index: false },
5252
},
5353
},
54-
sort: { type: 'keyword' },
54+
sort: { type: 'keyword', index: false },
5555
title: { type: 'text' },
5656
version: { type: 'integer' },
5757
},
5858
},
59-
migrations: searchSavedObjectTypeMigrations,
59+
migrations: searchMigrations,
6060
};

src/plugins/discover/server/search_migrations.test.ts renamed to src/plugins/discover/server/saved_objects/search_migrations.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
*/
1919

2020
import { SavedObjectMigrationContext } from 'kibana/server';
21-
import { searchSavedObjectTypeMigrations } from './search_migrations';
21+
import { searchMigrations } from './search_migrations';
2222

2323
const savedObjectMigrationContext = (null as unknown) as SavedObjectMigrationContext;
2424

2525
describe('migration search', () => {
2626
describe('6.7.2', () => {
27-
const migrationFn = searchSavedObjectTypeMigrations['6.7.2'];
27+
const migrationFn = searchMigrations['6.7.2'];
2828

2929
it('should migrate obsolete match_all query', () => {
3030
const migratedDoc = migrationFn(
@@ -56,7 +56,7 @@ describe('migration search', () => {
5656
});
5757

5858
describe('7.0.0', () => {
59-
const migrationFn = searchSavedObjectTypeMigrations['7.0.0'];
59+
const migrationFn = searchMigrations['7.0.0'];
6060

6161
test('skips errors when searchSourceJSON is null', () => {
6262
const doc = {
@@ -278,7 +278,7 @@ Object {
278278
});
279279

280280
describe('7.4.0', function () {
281-
const migrationFn = searchSavedObjectTypeMigrations['7.4.0'];
281+
const migrationFn = searchMigrations['7.4.0'];
282282

283283
test('transforms one dimensional sort arrays into two dimensional arrays', () => {
284284
const doc = {

src/plugins/discover/server/search_migrations.ts renamed to src/plugins/discover/server/saved_objects/search_migrations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import { flow, get } from 'lodash';
2121
import { SavedObjectMigrationFn } from 'kibana/server';
22-
import { DEFAULT_QUERY_LANGUAGE } from '../../data/common';
22+
import { DEFAULT_QUERY_LANGUAGE } from '../../../data/common';
2323

2424
const migrateMatchAllQuery: SavedObjectMigrationFn<any, any> = (doc) => {
2525
const searchSourceJSON = get<string>(doc, 'attributes.kibanaSavedObjectMeta.searchSourceJSON');
@@ -121,7 +121,7 @@ const migrateSearchSortToNestedArray: SavedObjectMigrationFn<any, any> = (doc) =
121121
};
122122
};
123123

124-
export const searchSavedObjectTypeMigrations = {
124+
export const searchMigrations = {
125125
'6.7.2': flow<SavedObjectMigrationFn<any, any>>(migrateMatchAllQuery),
126126
'7.0.0': flow<SavedObjectMigrationFn<any, any>>(setNewReferences),
127127
'7.4.0': flow<SavedObjectMigrationFn<any, any>>(migrateSearchSortToNestedArray),

0 commit comments

Comments
 (0)