diff --git a/src/platform/packages/shared/kbn-saved-search-component/src/components/saved_search.tsx b/src/platform/packages/shared/kbn-saved-search-component/src/components/saved_search.tsx index 48eb65f102bf7..631d17b585acd 100644 --- a/src/platform/packages/shared/kbn-saved-search-component/src/components/saved_search.tsx +++ b/src/platform/packages/shared/kbn-saved-search-component/src/components/saved_search.tsx @@ -16,7 +16,7 @@ import type { } from '@kbn/discover-plugin/public'; import { SerializedPanelState } from '@kbn/presentation-publishing'; import { css } from '@emotion/react'; -import { SavedSearchAttributes } from '@kbn/saved-search-plugin/common'; +import { type SavedSearch, toSavedSearchAttributes } from '@kbn/saved-search-plugin/common'; import { isOfAggregateQueryType } from '@kbn/es-query'; import { SavedSearchComponentProps } from '../types'; import { SavedSearchComponentErrorContent } from './error'; @@ -68,16 +68,21 @@ export const SavedSearchComponent: React.FC = (props) searchSource.setField('filter', filters); const { searchSourceJSON, references } = searchSource.serialize(); // By-value saved object structure - const attributes: Partial = { + const savedSearch: SavedSearch = { + searchSource, kibanaSavedObjectMeta: { searchSourceJSON, }, columns, sort: getDefaultSort(dataView, undefined, undefined, isOfAggregateQueryType(query)), + managed: false, }; setInitialSerializedState({ rawState: { - attributes: { ...attributes, references }, + attributes: { + ...toSavedSearchAttributes(savedSearch, searchSourceJSON), + references, + }, timeRange, nonPersistedDisplayOptions: { solutionNavIdOverride, diff --git a/src/platform/plugins/shared/discover/public/embeddable/constants.ts b/src/platform/plugins/shared/discover/public/embeddable/constants.ts index f32fd32b3f51a..33d5d4af6c81e 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/constants.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/constants.ts @@ -30,7 +30,7 @@ export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH'; export const DEFAULT_HEADER_ROW_HEIGHT_LINES = 3; /** This constant refers to the parts of the saved search state that can be edited from a dashboard */ -export const EDITABLE_SAVED_SEARCH_KEYS: Readonly> = [ +export const EDITABLE_SAVED_SEARCH_KEYS = [ 'sort', 'columns', 'rowHeight', @@ -39,7 +39,7 @@ export const EDITABLE_SAVED_SEARCH_KEYS: Readonly; /** This constant refers to the dashboard panel specific state */ export const EDITABLE_PANEL_KEYS: Readonly> = [ diff --git a/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.test.ts b/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.test.ts index 7784e4ed1ae92..26485fcb84827 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.test.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.test.ts @@ -16,10 +16,28 @@ import type { SavedSearchUnwrapResult } from '@kbn/saved-search-plugin/public'; import { discoverServiceMock } from '../../__mocks__/services'; import type { SearchEmbeddableSerializedState } from '../types'; import { deserializeState, serializeState } from './serialization_utils'; +import type { DiscoverSessionTab } from '@kbn/saved-search-plugin/server'; describe('Serialization utils', () => { const uuid = 'mySearchEmbeddable'; + const tabs: DiscoverSessionTab[] = [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + kibanaSavedObjectMeta: { + searchSourceJSON: '{"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', + }, + sort: [['order_date', 'desc']], + columns: ['_source'], + grid: {}, + hideChart: false, + sampleSize: 100, + isTextBasedQuery: false, + }, + }, + ]; const mockedSavedSearchAttributes: SearchEmbeddableSerializedState['attributes'] = { kibanaSavedObjectMeta: { searchSourceJSON: '{"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', @@ -32,6 +50,7 @@ describe('Serialization utils', () => { hideChart: false, sampleSize: 100, isTextBasedQuery: false, + tabs, references: [ { name: 'kibanaSavedObjectMeta.searchSourceJSON.index', diff --git a/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.ts b/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.ts index 12a2b5fc20829..a84442d7759c0 100644 --- a/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.ts +++ b/src/platform/plugins/shared/discover/public/embeddable/utils/serialization_utils.ts @@ -106,13 +106,14 @@ export const serializeState = ({ if (savedObjectId) { const editableAttributesBackup = initialState.rawSavedObjectAttributes ?? {}; + const [{ attributes }] = savedSearchAttributes.tabs; // only save the current state that is **different** than the saved object state const overwriteState = EDITABLE_SAVED_SEARCH_KEYS.reduce((prev, key) => { - if (deepEqual(savedSearchAttributes[key], editableAttributesBackup[key])) { + if (deepEqual(attributes[key], editableAttributesBackup[key])) { return prev; } - return { ...prev, [key]: savedSearchAttributes[key] }; + return { ...prev, [key]: attributes[key] }; }, {}); return { diff --git a/src/platform/plugins/shared/discover/server/locator/columns_from_locator.test.ts b/src/platform/plugins/shared/discover/server/locator/columns_from_locator.test.ts index 2d0a435edec89..7c2776f0cbcda 100644 --- a/src/platform/plugins/shared/discover/server/locator/columns_from_locator.test.ts +++ b/src/platform/plugins/shared/discover/server/locator/columns_from_locator.test.ts @@ -15,6 +15,7 @@ import { dataPluginMock } from '@kbn/data-plugin/server/mocks'; import type { DataView } from '@kbn/data-views-plugin/common'; import { createStubDataView } from '@kbn/data-views-plugin/common/stubs'; import type { SavedSearchAttributes } from '@kbn/saved-search-plugin/common'; +import type { DiscoverSessionTabAttributes } from '@kbn/saved-search-plugin/server'; import type { LocatorServicesDeps as Services } from '.'; import type { DiscoverAppLocatorParams } from '../../common'; import { DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils'; @@ -37,6 +38,20 @@ const defaultSavedSearch: SavedObject = { searchSourceJSON: '{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"testIndexRefName"}', }, + tabs: [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + columns: ['response', 'url', 'clientip', 'machine.os', 'tags'], + sort: [['test', '134']], + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"testIndexRefName"}', + }, + }, + }, + ], } as unknown as SavedSearchAttributes, }; @@ -135,7 +150,26 @@ test('with search source using columns when DOC_HIDE_TIME_COLUMN_SETTING is true }); test('with saved search containing ["_source"]', async () => { - mockSavedSearch.attributes.columns = ['_source']; + mockSavedSearch = { + ...defaultSavedSearch, + attributes: { + ...defaultSavedSearch.attributes, + tabs: [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + columns: ['_source'], + sort: [['test', '134']], + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"testIndexRefName"}', + }, + } as DiscoverSessionTabAttributes, + }, + ], + }, + }; const provider = columnsFromLocatorFactory(mockServices); const columns = await provider(mockPayload[0].params); diff --git a/src/platform/plugins/shared/discover/server/locator/searchsource_from_locator.test.ts b/src/platform/plugins/shared/discover/server/locator/searchsource_from_locator.test.ts index e1fd88029065c..460ae4cab206b 100644 --- a/src/platform/plugins/shared/discover/server/locator/searchsource_from_locator.test.ts +++ b/src/platform/plugins/shared/discover/server/locator/searchsource_from_locator.test.ts @@ -15,6 +15,7 @@ import { dataPluginMock } from '@kbn/data-plugin/server/mocks'; import type { DataView } from '@kbn/data-views-plugin/common'; import { createStubDataView } from '@kbn/data-views-plugin/common/stubs'; import type { SavedSearchAttributes } from '@kbn/saved-search-plugin/common'; +import type { DiscoverSessionTabAttributes } from '@kbn/saved-search-plugin/server'; import type { LocatorServicesDeps as Services } from '.'; import type { DiscoverAppLocatorParams } from '../../common'; import { DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils'; @@ -37,6 +38,20 @@ const defaultSavedSearch: SavedObject = { searchSourceJSON: '{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"testIndexRefName"}', }, + tabs: [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + columns: ['response', 'url', 'clientip', 'machine.os', 'tags'], + sort: [['test', '134']], + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"testIndexRefName"}', + }, + }, + }, + ], } as unknown as SavedSearchAttributes, }; @@ -172,7 +187,26 @@ test('with locator params containing a timeRange', async () => { }); test('with saved search containing ["_source"]', async () => { - mockSavedSearch.attributes.columns = ['_source']; + mockSavedSearch = { + ...defaultSavedSearch, + attributes: { + ...defaultSavedSearch.attributes, + tabs: [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + columns: ['_source'], + sort: [['test', '134']], + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"testIndexRefName"}', + }, + } as DiscoverSessionTabAttributes, + }, + ], + }, + }; const provider = searchSourceFromLocatorFactory(mockServices); const searchSource = await provider(mockPayload[0].params); diff --git a/src/platform/plugins/shared/saved_search/common/expressions/kibana_context.test.ts b/src/platform/plugins/shared/saved_search/common/expressions/kibana_context.test.ts index df8fcedb0e6fa..9a5bccaa9b2c4 100644 --- a/src/platform/plugins/shared/saved_search/common/expressions/kibana_context.test.ts +++ b/src/platform/plugins/shared/saved_search/common/expressions/kibana_context.test.ts @@ -13,7 +13,6 @@ import type { ExecutionContext } from '@kbn/expressions-plugin/common'; import type { KibanaContext, ExpressionFunctionKibanaContext } from '@kbn/data-plugin/common'; import { fromSavedSearchAttributes } from '../service/saved_searches_utils'; import type { SavedSearchAttributes, SavedSearch } from '../types'; - import type { KibanaContextStartDependencies } from './kibana_context'; import { getKibanaContextFn } from './kibana_context'; @@ -57,6 +56,19 @@ describe('kibanaContextFn', () => { query: [], }), }, + tabs: [ + { + id: 'test', + label: 'Test', + attributes: { + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + query: [], + }), + }, + }, + }, + ], } as SavedSearchAttributes, [], undefined, diff --git a/src/platform/plugins/shared/saved_search/common/saved_searches_utils.ts b/src/platform/plugins/shared/saved_search/common/saved_searches_utils.ts index bbc48c5b64e5b..603d6aa0c35bc 100644 --- a/src/platform/plugins/shared/saved_search/common/saved_searches_utils.ts +++ b/src/platform/plugins/shared/saved_search/common/saved_searches_utils.ts @@ -16,21 +16,22 @@ export const fromSavedSearchAttributes = < ReturnType = Serialized extends true ? SerializableSavedSearch : SavedSearch >( id: string | undefined, - attributes: SavedSearchAttributes, + { title, description, tabs }: SavedSearchAttributes, tags: string[] | undefined, searchSource: SavedSearch['searchSource'] | SerializedSearchSourceFields, managed: boolean, serialized: Serialized = false as Serialized -) => - ({ +) => { + const [{ attributes }] = tabs; + return { id, ...(serialized ? { serializedSearchSource: searchSource as SerializedSearchSourceFields } : { searchSource }), - title: attributes.title, + title, sort: attributes.sort, columns: attributes.columns, - description: attributes.description, + description, tags, grid: attributes.grid, hideChart: attributes.hideChart, @@ -48,6 +49,7 @@ export const fromSavedSearchAttributes = < breakdownField: attributes.breakdownField, visContext: attributes.visContext, density: attributes.density, - tabs: attributes.tabs, + tabs, managed, - } as ReturnType); + } as ReturnType; +}; diff --git a/src/platform/plugins/shared/saved_search/common/service/get_saved_searches.test.ts b/src/platform/plugins/shared/saved_search/common/service/get_saved_searches.test.ts index 2f68f2f0eecbe..8eb68ecfefcf0 100644 --- a/src/platform/plugins/shared/saved_search/common/service/get_saved_searches.test.ts +++ b/src/platform/plugins/shared/saved_search/common/service/get_saved_searches.test.ts @@ -61,6 +61,23 @@ describe('getSavedSearch', () => { grid: {}, hideChart: false, sampleSize: 100, + tabs: [ + { + id: 'my_tab', + label: 'My Tab', + attributes: { + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', + }, + sort: [['order_date', 'desc']], + columns: ['_source'], + grid: {}, + hideChart: false, + sampleSize: 100, + }, + }, + ], }, id: 'ccf1af80-2297-11ec-86e0-1155ffb9c7a7', type: 'search', @@ -145,7 +162,29 @@ describe('getSavedSearch', () => { "desc", ], ], - "tabs": undefined, + "tabs": Array [ + Object { + "attributes": Object { + "columns": Array [ + "_source", + ], + "grid": Object {}, + "hideChart": false, + "kibanaSavedObjectMeta": Object { + "searchSourceJSON": "{\\"query\\":{\\"query\\":\\"\\",\\"language\\":\\"kuery\\"},\\"filter\\":[],\\"indexRefName\\":\\"kibanaSavedObjectMeta.searchSourceJSON.index\\"}", + }, + "sampleSize": 100, + "sort": Array [ + Array [ + "order_date", + "desc", + ], + ], + }, + "id": "my_tab", + "label": "My Tab", + }, + ], "tags": undefined, "timeRange": undefined, "timeRestore": undefined, @@ -172,6 +211,23 @@ describe('getSavedSearch', () => { grid: {}, hideChart: true, isTextBasedQuery: true, + tabs: [ + { + id: 'my_tab', + label: 'My Tab', + attributes: { + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"sql":"SELECT * FROM foo"},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', + }, + sort: [['order_date', 'desc']], + columns: ['_source'], + grid: {}, + hideChart: true, + isTextBasedQuery: true, + }, + }, + ], }, id: 'ccf1af80-2297-11ec-86e0-1155ffb9c7a7', type: 'search', @@ -256,7 +312,29 @@ describe('getSavedSearch', () => { "desc", ], ], - "tabs": undefined, + "tabs": Array [ + Object { + "attributes": Object { + "columns": Array [ + "_source", + ], + "grid": Object {}, + "hideChart": true, + "isTextBasedQuery": true, + "kibanaSavedObjectMeta": Object { + "searchSourceJSON": "{\\"query\\":{\\"sql\\":\\"SELECT * FROM foo\\"},\\"filter\\":[],\\"indexRefName\\":\\"kibanaSavedObjectMeta.searchSourceJSON.index\\"}", + }, + "sort": Array [ + Array [ + "order_date", + "desc", + ], + ], + }, + "id": "my_tab", + "label": "My Tab", + }, + ], "tags": undefined, "timeRange": undefined, "timeRestore": undefined, @@ -283,6 +361,23 @@ describe('getSavedSearch', () => { grid: {}, hideChart: true, isTextBasedQuery: true, + tabs: [ + { + id: 'my_tab', + label: 'My Tab', + attributes: { + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"sql":"SELECT * FROM foo"},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', + }, + sort: [['order_date', 'desc']], + columns: ['_source'], + grid: {}, + hideChart: true, + isTextBasedQuery: true, + }, + }, + ], }, id: 'ccf1af80-2297-11ec-86e0-1155ffb9c7a7', type: 'search', diff --git a/src/platform/plugins/shared/saved_search/common/service/saved_searches_utils.test.ts b/src/platform/plugins/shared/saved_search/common/service/saved_searches_utils.test.ts index fe71a4a355d3f..a4c278ea9bfdc 100644 --- a/src/platform/plugins/shared/saved_search/common/service/saved_searches_utils.test.ts +++ b/src/platform/plugins/shared/saved_search/common/service/saved_searches_utils.test.ts @@ -12,10 +12,29 @@ import { fromSavedSearchAttributes, toSavedSearchAttributes } from './saved_sear import { createSearchSourceMock } from '@kbn/data-plugin/public/mocks'; import type { SavedSearch, SavedSearchAttributes } from '../types'; +import type { DiscoverSessionTab } from '../../server'; describe('saved_searches_utils', () => { describe('fromSavedSearchAttributes', () => { test('should convert attributes into SavedSearch', () => { + const tabs: DiscoverSessionTab[] = [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + kibanaSavedObjectMeta: { searchSourceJSON: '{}' }, + sort: [], + columns: ['a', 'b'], + grid: {}, + hideChart: true, + isTextBasedQuery: false, + usesAdHocDataView: false, + rowsPerPage: 250, + sampleSize: 1000, + breakdownField: 'extension.keyword', + }, + }, + ]; const attributes: SavedSearchAttributes = { kibanaSavedObjectMeta: { searchSourceJSON: '{}' }, title: 'saved search', @@ -29,6 +48,7 @@ describe('saved_searches_utils', () => { rowsPerPage: 250, sampleSize: 1000, breakdownField: 'extension.keyword', + tabs, }; expect( @@ -88,7 +108,29 @@ describe('saved_searches_utils', () => { }, "sharingSavedObjectProps": Object {}, "sort": Array [], - "tabs": undefined, + "tabs": Array [ + Object { + "attributes": Object { + "breakdownField": "extension.keyword", + "columns": Array [ + "a", + "b", + ], + "grid": Object {}, + "hideChart": true, + "isTextBasedQuery": false, + "kibanaSavedObjectMeta": Object { + "searchSourceJSON": "{}", + }, + "rowsPerPage": 250, + "sampleSize": 1000, + "sort": Array [], + "usesAdHocDataView": false, + }, + "id": "tab-1", + "label": "Tab 1", + }, + ], "tags": Array [ "tags-1", "tags-2", diff --git a/src/platform/plugins/shared/saved_search/common/types.ts b/src/platform/plugins/shared/saved_search/common/types.ts index f24cbc1cdc8c4..34f26fd2f3c18 100644 --- a/src/platform/plugins/shared/saved_search/common/types.ts +++ b/src/platform/plugins/shared/saved_search/common/types.ts @@ -71,7 +71,7 @@ export interface SavedSearchAttributes { density?: DataGridDensity; visContext?: VisContextUnmapped; - tabs?: DiscoverSessionTab[]; + tabs: DiscoverSessionTab[]; } /** @internal **/ diff --git a/src/platform/plugins/shared/saved_search/public/services/saved_searches/to_saved_search.test.ts b/src/platform/plugins/shared/saved_search/public/services/saved_searches/to_saved_search.test.ts index 3aa69f898c9da..f1b0eee6355df 100644 --- a/src/platform/plugins/shared/saved_search/public/services/saved_searches/to_saved_search.test.ts +++ b/src/platform/plugins/shared/saved_search/public/services/saved_searches/to_saved_search.test.ts @@ -12,6 +12,7 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { spacesPluginMock } from '@kbn/spaces-plugin/public/mocks'; import type { SavedSearchByValueAttributes } from '.'; import { byValueToSavedSearch } from '.'; +import type { DiscoverSessionTab } from '../../../server'; const mockServices = { contentManagement: contentManagementMock.createStartContract().client, @@ -21,6 +22,20 @@ const mockServices = { describe('toSavedSearch', () => { it('succesfully converts attributes to saved search', async () => { + const tabs: DiscoverSessionTab[] = [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + kibanaSavedObjectMeta: { searchSourceJSON: '{}' }, + sort: [['@timestamp', 'desc']], + columns: ['message', 'extension'], + grid: {}, + hideChart: false, + isTextBasedQuery: false, + }, + }, + ]; const attributes: SavedSearchByValueAttributes = { title: 'saved-search-title', sort: [['@timestamp', 'desc']], @@ -31,6 +46,7 @@ describe('toSavedSearch', () => { kibanaSavedObjectMeta: { searchSourceJSON: '{}', }, + tabs, references: [ { id: '1', @@ -100,7 +116,162 @@ describe('toSavedSearch', () => { "desc", ], ], - "tabs": undefined, + "tabs": Array [ + Object { + "attributes": Object { + "columns": Array [ + "message", + "extension", + ], + "grid": Object {}, + "hideChart": false, + "isTextBasedQuery": false, + "kibanaSavedObjectMeta": Object { + "searchSourceJSON": "{}", + }, + "sort": Array [ + Array [ + "@timestamp", + "desc", + ], + ], + }, + "id": "tab-1", + "label": "Tab 1", + }, + ], + "tags": undefined, + "timeRange": undefined, + "timeRestore": undefined, + "title": "saved-search-title", + "usesAdHocDataView": undefined, + "viewMode": undefined, + "visContext": undefined, + } + `); + }); + + it('uses attributes from `tabs`', async () => { + const tabs: DiscoverSessionTab[] = [ + { + id: 'tab-1', + label: 'Tab 1', + attributes: { + kibanaSavedObjectMeta: { searchSourceJSON: '{}' }, + sort: [['my_tab_sort', 'desc']], + columns: ['my', 'tab', 'columns'], + grid: {}, + hideChart: false, + isTextBasedQuery: false, + }, + }, + ]; + const attributes: SavedSearchByValueAttributes = { + title: 'saved-search-title', + sort: [['@timestamp', 'desc']], + columns: ['message', 'extension'], + grid: {}, + hideChart: false, + isTextBasedQuery: false, + kibanaSavedObjectMeta: { + searchSourceJSON: '{}', + }, + tabs, + references: [ + { + id: '1', + name: 'ref_0', + type: 'index-pattern', + }, + ], + }; + const savedSearch = await byValueToSavedSearch({ attributes }, mockServices); + expect(savedSearch).toMatchInlineSnapshot(` + Object { + "breakdownField": undefined, + "columns": Array [ + "my", + "tab", + "columns", + ], + "density": undefined, + "description": "", + "grid": Object {}, + "headerRowHeight": undefined, + "hideAggregatedPreview": undefined, + "hideChart": false, + "id": undefined, + "isTextBasedQuery": false, + "managed": false, + "references": Array [ + Object { + "id": "1", + "name": "ref_0", + "type": "index-pattern", + }, + ], + "refreshInterval": undefined, + "rowHeight": undefined, + "rowsPerPage": undefined, + "sampleSize": undefined, + "searchSource": Object { + "create": [MockFunction], + "createChild": [MockFunction], + "createCopy": [MockFunction], + "destroy": [MockFunction], + "fetch": [MockFunction], + "fetch$": [MockFunction], + "getActiveIndexFilter": [MockFunction], + "getField": [MockFunction], + "getFields": [MockFunction], + "getId": [MockFunction], + "getOwnField": [MockFunction], + "getParent": [MockFunction], + "getSearchRequestBody": [MockFunction], + "getSerializedFields": [MockFunction], + "history": Array [], + "loadDataViewFields": [MockFunction], + "onRequestStart": [MockFunction], + "parseActiveIndexPatternFromQueryString": [MockFunction], + "removeField": [MockFunction], + "serialize": [MockFunction], + "setField": [MockFunction], + "setOverwriteDataViewType": [MockFunction], + "setParent": [MockFunction], + "toExpressionAst": [MockFunction], + }, + "sharingSavedObjectProps": undefined, + "sort": Array [ + Array [ + "my_tab_sort", + "desc", + ], + ], + "tabs": Array [ + Object { + "attributes": Object { + "columns": Array [ + "my", + "tab", + "columns", + ], + "grid": Object {}, + "hideChart": false, + "isTextBasedQuery": false, + "kibanaSavedObjectMeta": Object { + "searchSourceJSON": "{}", + }, + "sort": Array [ + Array [ + "my_tab_sort", + "desc", + ], + ], + }, + "id": "tab-1", + "label": "Tab 1", + }, + ], "tags": undefined, "timeRange": undefined, "timeRestore": undefined, diff --git a/src/platform/plugins/shared/saved_search/server/index.ts b/src/platform/plugins/shared/saved_search/server/index.ts index 3e6f666bb98f0..c70086daec672 100644 --- a/src/platform/plugins/shared/saved_search/server/index.ts +++ b/src/platform/plugins/shared/saved_search/server/index.ts @@ -9,7 +9,7 @@ import type { PluginInitializerContext } from '@kbn/core-plugins-server'; -export type { DiscoverSessionTab } from './saved_objects/schema'; +export type { DiscoverSessionTab, DiscoverSessionTabAttributes } from './saved_objects/schema'; export { getSavedSearch } from './services/saved_searches'; export const plugin = async (initContext: PluginInitializerContext) => { diff --git a/src/platform/plugins/shared/saved_search/server/saved_objects/index.ts b/src/platform/plugins/shared/saved_search/server/saved_objects/index.ts index 4014c92918ad4..7b95b11007299 100644 --- a/src/platform/plugins/shared/saved_search/server/saved_objects/index.ts +++ b/src/platform/plugins/shared/saved_search/server/saved_objects/index.ts @@ -7,5 +7,5 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export type { DiscoverSessionTab } from './schema'; +export type { DiscoverSessionTab, DiscoverSessionTabAttributes } from './schema'; export { getSavedSearchObjectType } from './search'; diff --git a/src/platform/plugins/shared/saved_search/server/saved_objects/schema.ts b/src/platform/plugins/shared/saved_search/server/saved_objects/schema.ts index 3a35d8fb53434..a8fc5aa53da6a 100644 --- a/src/platform/plugins/shared/saved_search/server/saved_objects/schema.ts +++ b/src/platform/plugins/shared/saved_search/server/saved_objects/schema.ts @@ -138,16 +138,19 @@ export const SCHEMA_SEARCH_MODEL_VERSION_5 = SCHEMA_SEARCH_MODEL_VERSION_4.exten ), }); +const DISCOVER_SESSION_TAB_ATTRIBUTES = SCHEMA_SEARCH_MODEL_VERSION_5.extends({ + title: undefined, + description: undefined, +}); + const SCHEMA_DISCOVER_SESSION_TAB = schema.object({ id: schema.string(), label: schema.string(), // Remove `title` and `description` from the tab schema as they exist at the top level of the saved object - attributes: SCHEMA_SEARCH_MODEL_VERSION_5.extends({ - title: undefined, - description: undefined, - }), + attributes: DISCOVER_SESSION_TAB_ATTRIBUTES, }); +export type DiscoverSessionTabAttributes = TypeOf; export type DiscoverSessionTab = TypeOf; export const SCHEMA_SEARCH_MODEL_VERSION_6 = SCHEMA_SEARCH_MODEL_VERSION_5.extends({ diff --git a/src/platform/plugins/shared/saved_search/server/services/saved_searches/get_saved_searches.ts b/src/platform/plugins/shared/saved_search/server/services/saved_searches/get_saved_searches.ts index 2e5a1c5299e79..09d3353472f0b 100644 --- a/src/platform/plugins/shared/saved_search/server/services/saved_searches/get_saved_searches.ts +++ b/src/platform/plugins/shared/saved_search/server/services/saved_searches/get_saved_searches.ts @@ -24,8 +24,9 @@ export const getSavedSearch = async (savedSearchId: string, deps: GetSavedSearch savedSearchId ); + const [{ attributes }] = savedSearch.attributes.tabs; const parsedSearchSourceJSON = parseSearchSourceJSON( - savedSearch.attributes.kibanaSavedObjectMeta?.searchSourceJSON ?? '{}' + attributes.kibanaSavedObjectMeta?.searchSourceJSON ?? '{}' ); const searchSourceValues = injectReferences( diff --git a/x-pack/platform/plugins/shared/fleet/kibana.jsonc b/x-pack/platform/plugins/shared/fleet/kibana.jsonc index ca130b2d9cb51..1d7f884d8130a 100644 --- a/x-pack/platform/plugins/shared/fleet/kibana.jsonc +++ b/x-pack/platform/plugins/shared/fleet/kibana.jsonc @@ -31,6 +31,7 @@ "fieldsMetadata", "logsDataAccess", "embeddable", + "savedSearch", "spaces" ], "optionalPlugins": [ diff --git a/x-pack/platform/plugins/shared/logs_shared/kibana.jsonc b/x-pack/platform/plugins/shared/logs_shared/kibana.jsonc index a175a057d30fe..e4b6aaf384018 100644 --- a/x-pack/platform/plugins/shared/logs_shared/kibana.jsonc +++ b/x-pack/platform/plugins/shared/logs_shared/kibana.jsonc @@ -25,6 +25,7 @@ "uiActions", "usageCollection", "embeddable", + "savedSearch" ], "optionalPlugins": [ "observabilityAIAssistant", diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts index 89ab8bdc02efb..6029217a8bc17 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts @@ -40,6 +40,22 @@ describe('createSearchItems', () => { grid: {}, hideChart: false, isTextBasedQuery: false, + tabs: [ + { + id: 'tab_0', + label: 'label_0', + attributes: { + columns: ['_source'], + sort: [], + kibanaSavedObjectMeta: { + searchSourceJSON: '', + }, + grid: {}, + hideChart: false, + isTextBasedQuery: false, + }, + }, + ], }, [], { diff --git a/x-pack/platform/test/api_integration/services/ml/test_resources.ts b/x-pack/platform/test/api_integration/services/ml/test_resources.ts index 95b222857b924..0e4a303e312c9 100644 --- a/x-pack/platform/test/api_integration/services/ml/test_resources.ts +++ b/x-pack/platform/test/api_integration/services/ml/test_resources.ts @@ -245,11 +245,6 @@ export function MachineLearningTestResourcesProvider( } }); - // make searchSourceJSON node a string - const searchSourceJsonNode = updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON; - const searchSourceJsonString = JSON.stringify(searchSourceJsonNode); - updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON = searchSourceJsonString; - return updatedBody; }, diff --git a/x-pack/platform/test/api_integration/services/ml/test_resources_data.ts b/x-pack/platform/test/api_integration/services/ml/test_resources_data.ts index ac5c2241de81f..e61b1db3bc896 100644 --- a/x-pack/platform/test/api_integration/services/ml/test_resources_data.ts +++ b/x-pack/platform/test/api_integration/services/ml/test_resources_data.ts @@ -11,12 +11,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -52,8 +50,57 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: '', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -69,12 +116,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_lucene', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -83,8 +128,30 @@ export const savedSearches = { }, filter: [], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'airline:A*', + language: 'lucene', + }, + filter: [], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -100,12 +167,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_kuery', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -114,8 +179,30 @@ export const savedSearches = { }, filter: [], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'airline: A* and responsetime > 5', + language: 'kuery', + }, + filter: [], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -131,12 +218,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_and_lucene', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -172,8 +257,57 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime:>50', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -189,12 +323,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_and_kuery', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -230,8 +362,57 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime > 49', + language: 'kuery', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -247,12 +428,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_two_and_lucene', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -293,8 +472,62 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime:>50', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrases', + key: 'airline', + params: ['ASA', 'AAL'], + }, + query: { + bool: { + should: [ + { + match_phrase: { + airline: 'ASA', + }, + }, + { + match_phrase: { + airline: 'AAL', + }, + }, + ], + minimum_should_match: 1, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -310,12 +543,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_two_and_kuery', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -356,8 +587,62 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime > 49', + language: 'kuery', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrases', + key: 'airline', + params: ['ASA', 'FFT'], + }, + query: { + bool: { + should: [ + { + match_phrase: { + airline: 'ASA', + }, + }, + { + match_phrase: { + airline: 'FFT', + }, + }, + ], + minimum_should_match: 1, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { diff --git a/x-pack/platform/test/functional/apps/discover/group3/saved_search_embeddable.ts b/x-pack/platform/test/functional/apps/discover/group3/saved_search_embeddable.ts index 605a7e20bf9e1..0436c0049606c 100644 --- a/x-pack/platform/test/functional/apps/discover/group3/saved_search_embeddable.ts +++ b/x-pack/platform/test/functional/apps/discover/group3/saved_search_embeddable.ts @@ -93,6 +93,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { searchSourceJSON: '{"highlightAll":true,"version":true,"query":{"language":"lucene","query":""},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', }, + tabs: [ + { + id: 'my_tab', + label: 'My Tab', + attributes: { + columns: ['agent', 'bytes', 'clientip'], + sort: [['@timestamp', 'desc']], + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"highlightAll":true,"version":true,"query":{"language":"lucene","query":""},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', + }, + }, + }, + ], }, references: [ { diff --git a/x-pack/platform/test/functional/services/ml/test_resources.ts b/x-pack/platform/test/functional/services/ml/test_resources.ts index 915060b152f24..642b59d016555 100644 --- a/x-pack/platform/test/functional/services/ml/test_resources.ts +++ b/x-pack/platform/test/functional/services/ml/test_resources.ts @@ -246,11 +246,6 @@ export function MachineLearningTestResourcesProvider( } }); - // make searchSourceJSON node a string - const searchSourceJsonNode = updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON; - const searchSourceJsonString = JSON.stringify(searchSourceJsonNode); - updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON = searchSourceJsonString; - return updatedBody; }, diff --git a/x-pack/platform/test/functional/services/ml/test_resources_data.ts b/x-pack/platform/test/functional/services/ml/test_resources_data.ts index ac5c2241de81f..e61b1db3bc896 100644 --- a/x-pack/platform/test/functional/services/ml/test_resources_data.ts +++ b/x-pack/platform/test/functional/services/ml/test_resources_data.ts @@ -11,12 +11,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -52,8 +50,57 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: '', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -69,12 +116,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_lucene', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -83,8 +128,30 @@ export const savedSearches = { }, filter: [], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'airline:A*', + language: 'lucene', + }, + filter: [], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -100,12 +167,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_kuery', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -114,8 +179,30 @@ export const savedSearches = { }, filter: [], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'airline: A* and responsetime > 5', + language: 'kuery', + }, + filter: [], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -131,12 +218,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_and_lucene', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -172,8 +257,57 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime:>50', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -189,12 +323,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_and_kuery', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -230,8 +362,57 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime > 49', + language: 'kuery', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -247,12 +428,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_two_and_lucene', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -293,8 +472,62 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime:>50', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrases', + key: 'airline', + params: ['ASA', 'AAL'], + }, + query: { + bool: { + should: [ + { + match_phrase: { + airline: 'ASA', + }, + }, + { + match_phrase: { + airline: 'AAL', + }, + }, + ], + minimum_should_match: 1, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { @@ -310,12 +543,10 @@ export const savedSearches = { attributes: { title: 'ft_farequote_filter_two_and_kuery', description: '', - hits: 0, columns: ['_source'], sort: ['@timestamp', 'desc'], - version: 1, kibanaSavedObjectMeta: { - searchSourceJSON: { + searchSourceJSON: JSON.stringify({ highlightAll: true, version: true, query: { @@ -356,8 +587,62 @@ export const savedSearches = { }, ], indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', - }, + }), }, + tabs: [ + { + id: 'tab_0', + label: 'My Tab', + attributes: { + columns: ['_source'], + sort: ['@timestamp', 'desc'], + kibanaSavedObjectMeta: { + searchSourceJSON: JSON.stringify({ + highlightAll: true, + version: true, + query: { + query: 'responsetime > 49', + language: 'kuery', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrases', + key: 'airline', + params: ['ASA', 'FFT'], + }, + query: { + bool: { + should: [ + { + match_phrase: { + airline: 'ASA', + }, + }, + { + match_phrase: { + airline: 'FFT', + }, + }, + ], + minimum_should_match: 1, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }), + }, + }, + }, + ], }, references: [ { diff --git a/x-pack/solutions/observability/plugins/infra/kibana.jsonc b/x-pack/solutions/observability/plugins/infra/kibana.jsonc index dd4ddeb710062..b5b67f29352a9 100644 --- a/x-pack/solutions/observability/plugins/infra/kibana.jsonc +++ b/x-pack/solutions/observability/plugins/infra/kibana.jsonc @@ -28,6 +28,7 @@ "observability", "observabilityShared", "ruleRegistry", + "savedSearch", "security", "share", "triggersActionsUi",