diff --git a/src/plugins/data/server/saved_objects/index.ts b/src/plugins/data/server/saved_objects/index.ts index 4326200141179..102183fc1c5ed 100644 --- a/src/plugins/data/server/saved_objects/index.ts +++ b/src/plugins/data/server/saved_objects/index.ts @@ -16,8 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - -export { searchSavedObjectType } from './search'; export { querySavedObjectType } from './query'; export { indexPatternSavedObjectType } from './index_patterns'; export { kqlTelemetry } from './kql_telementry'; diff --git a/src/plugins/data/server/search/search_service.ts b/src/plugins/data/server/search/search_service.ts index df809b425eb9e..34ed8c6c6f401 100644 --- a/src/plugins/data/server/search/search_service.ts +++ b/src/plugins/data/server/search/search_service.ts @@ -27,7 +27,6 @@ import { } from './types'; import { registerSearchRoute } from './routes'; import { ES_SEARCH_STRATEGY, esSearchStrategyProvider } from './es_search'; -import { searchSavedObjectType } from '../saved_objects'; import { DataPluginStart } from '../plugin'; export class SearchService implements Plugin { @@ -36,8 +35,6 @@ export class SearchService implements Plugin { constructor(private initializerContext: PluginInitializerContext) {} public setup(core: CoreSetup): ISearchSetup { - core.savedObjects.registerType(searchSavedObjectType); - this.registerSearchStrategy( ES_SEARCH_STRATEGY, esSearchStrategyProvider(this.initializerContext.config.legacy.globalConfig$) diff --git a/src/plugins/discover/server/plugin.ts b/src/plugins/discover/server/plugin.ts index a7445a5189163..77553ce644839 100644 --- a/src/plugins/discover/server/plugin.ts +++ b/src/plugins/discover/server/plugin.ts @@ -20,11 +20,13 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/server'; import { uiSettings } from './ui_settings'; import { capabilitiesProvider } from './capabilities_provider'; +import { searchSavedObjectType } from './saved_objects'; export class DiscoverServerPlugin implements Plugin { public setup(core: CoreSetup) { core.capabilities.registerProvider(capabilitiesProvider); core.uiSettings.register(uiSettings); + core.savedObjects.registerType(searchSavedObjectType); return {}; } diff --git a/src/plugins/discover/server/saved_objects/index.ts b/src/plugins/discover/server/saved_objects/index.ts new file mode 100644 index 0000000000000..efe785364ccb6 --- /dev/null +++ b/src/plugins/discover/server/saved_objects/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { searchSavedObjectType } from './search'; diff --git a/src/plugins/data/server/saved_objects/search.ts b/src/plugins/discover/server/saved_objects/search.ts similarity index 84% rename from src/plugins/data/server/saved_objects/search.ts rename to src/plugins/discover/server/saved_objects/search.ts index 16caaf05a0fc6..2348d89c4f4dd 100644 --- a/src/plugins/data/server/saved_objects/search.ts +++ b/src/plugins/discover/server/saved_objects/search.ts @@ -18,7 +18,7 @@ */ import { SavedObjectsType } from 'kibana/server'; -import { searchSavedObjectTypeMigrations } from './search_migrations'; +import { searchMigrations } from './search_migrations'; export const searchSavedObjectType: SavedObjectsType = { name: 'search', @@ -43,18 +43,18 @@ export const searchSavedObjectType: SavedObjectsType = { }, mappings: { properties: { - columns: { type: 'keyword' }, + columns: { type: 'keyword', index: false }, description: { type: 'text' }, - hits: { type: 'integer' }, + hits: { type: 'integer', index: false }, kibanaSavedObjectMeta: { properties: { - searchSourceJSON: { type: 'text' }, + searchSourceJSON: { type: 'text', index: false }, }, }, - sort: { type: 'keyword' }, + sort: { type: 'keyword', index: false }, title: { type: 'text' }, version: { type: 'integer' }, }, }, - migrations: searchSavedObjectTypeMigrations as any, + migrations: searchMigrations as any, }; diff --git a/src/plugins/data/server/saved_objects/search_migrations.test.ts b/src/plugins/discover/server/saved_objects/search_migrations.test.ts similarity index 96% rename from src/plugins/data/server/saved_objects/search_migrations.test.ts rename to src/plugins/discover/server/saved_objects/search_migrations.test.ts index 69db08a689255..babd25c03dbb2 100644 --- a/src/plugins/data/server/saved_objects/search_migrations.test.ts +++ b/src/plugins/discover/server/saved_objects/search_migrations.test.ts @@ -18,13 +18,13 @@ */ import { SavedObjectMigrationContext } from 'kibana/server'; -import { searchSavedObjectTypeMigrations } from './search_migrations'; +import { searchMigrations } from './search_migrations'; const savedObjectMigrationContext = (null as unknown) as SavedObjectMigrationContext; describe('migration search', () => { describe('6.7.2', () => { - const migrationFn = searchSavedObjectTypeMigrations['6.7.2']; + const migrationFn = searchMigrations['6.7.2']; it('should migrate obsolete match_all query', () => { const migratedDoc = migrationFn( @@ -56,7 +56,7 @@ describe('migration search', () => { }); describe('7.0.0', () => { - const migrationFn = searchSavedObjectTypeMigrations['7.0.0']; + const migrationFn = searchMigrations['7.0.0']; test('skips errors when searchSourceJSON is null', () => { const doc = { @@ -278,7 +278,7 @@ Object { }); describe('7.4.0', function () { - const migrationFn = searchSavedObjectTypeMigrations['7.4.0']; + const migrationFn = searchMigrations['7.4.0']; test('transforms one dimensional sort arrays into two dimensional arrays', () => { const doc = { diff --git a/src/plugins/data/server/saved_objects/search_migrations.ts b/src/plugins/discover/server/saved_objects/search_migrations.ts similarity index 97% rename from src/plugins/data/server/saved_objects/search_migrations.ts rename to src/plugins/discover/server/saved_objects/search_migrations.ts index 9bba429f8d71b..0302159c43c56 100644 --- a/src/plugins/data/server/saved_objects/search_migrations.ts +++ b/src/plugins/discover/server/saved_objects/search_migrations.ts @@ -19,7 +19,7 @@ import { flow, get } from 'lodash'; import { SavedObjectMigrationFn } from 'kibana/server'; -import { DEFAULT_QUERY_LANGUAGE } from '../../common'; +import { DEFAULT_QUERY_LANGUAGE } from '../../../data/common'; const migrateMatchAllQuery: SavedObjectMigrationFn = (doc) => { const searchSourceJSON = get(doc, 'attributes.kibanaSavedObjectMeta.searchSourceJSON'); @@ -121,7 +121,7 @@ const migrateSearchSortToNestedArray: SavedObjectMigrationFn = (doc) = }; }; -export const searchSavedObjectTypeMigrations = { +export const searchMigrations = { '6.7.2': flow(migrateMatchAllQuery), '7.0.0': flow(setNewReferences), '7.4.0': flow(migrateSearchSortToNestedArray),