mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Discover] [Saved Search] Cleanup saved search mappings (#154016)
## Summary This PR cleans up saved search mappings, removing all fields that aren't being searched or aggregated on. Continuation of the work started in #153129. ### Checklist - [ ] ~Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~ - [ ] ~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~ - [ ] ~[Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios~ - [ ] ~Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))~ - [ ] ~Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~ - [ ] ~If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~ - [ ] ~This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~ - [ ] ~This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)~ ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2a4415f1a4
commit
25b8f92753
6 changed files with 81 additions and 38 deletions
|
@ -125,7 +125,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
|
|||
"query": "ec6000b775f06f81470df42d23f7a88cb31d64ba",
|
||||
"rules-settings": "9854495c3b54b16a6625fb250c35e5504da72266",
|
||||
"sample-data-telemetry": "c38daf1a49ed24f2a4fb091e6e1e833fccf19935",
|
||||
"search": "01bc42d635e9ea0588741c4c7a2bbd3feb3ac5dc",
|
||||
"search": "ed3a9b1681b57d69560909d51933fdf17576ea68",
|
||||
"search-session": "58a44d14ec991739166b2ec28d718001ab0f4b28",
|
||||
"search-telemetry": "1bbaf2db531b97fa04399440fa52d46e86d54dd8",
|
||||
"security-rule": "1ff82dfb2298c3caf6888fc3ef15c6bf7a628877",
|
||||
|
|
|
@ -37,7 +37,7 @@ export interface SavedSearchAttributes {
|
|||
rowHeight?: number;
|
||||
|
||||
timeRestore?: boolean;
|
||||
timeRange?: TimeRange;
|
||||
timeRange?: Pick<TimeRange, 'from' | 'to'>;
|
||||
refreshInterval?: RefreshInterval;
|
||||
|
||||
rowsPerPage?: number;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { pick } from 'lodash';
|
||||
import type { SavedSearchAttributes } from '../../../common';
|
||||
import { fromSavedSearchAttributes as fromSavedSearchAttributesCommon } from '../../../common';
|
||||
import type { SavedSearch } from './types';
|
||||
|
@ -54,7 +55,7 @@ export const toSavedSearchAttributes = (
|
|||
isTextBasedQuery: savedSearch.isTextBasedQuery ?? false,
|
||||
usesAdHocDataView: savedSearch.usesAdHocDataView,
|
||||
timeRestore: savedSearch.timeRestore ?? false,
|
||||
timeRange: savedSearch.timeRange,
|
||||
timeRange: savedSearch.timeRange ? pick(savedSearch.timeRange, ['from', 'to']) : undefined,
|
||||
refreshInterval: savedSearch.refreshInterval,
|
||||
rowsPerPage: savedSearch.rowsPerPage,
|
||||
breakdownField: savedSearch.breakdownField,
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { SavedObjectsType } from '@kbn/core/server';
|
||||
import { MigrateFunctionsObject } from '@kbn/kibana-utils-plugin/common';
|
||||
import { VIEW_MODE } from '../../common';
|
||||
import { getAllMigrations } from './search_migrations';
|
||||
|
||||
export function getSavedSearchObjectType(
|
||||
|
@ -33,44 +35,83 @@ export function getSavedSearchObjectType(
|
|||
},
|
||||
},
|
||||
mappings: {
|
||||
dynamic: false,
|
||||
properties: {
|
||||
columns: { type: 'keyword', index: false, doc_values: false },
|
||||
description: { type: 'text' },
|
||||
viewMode: { type: 'keyword', index: false, doc_values: false },
|
||||
hideChart: { type: 'boolean', index: false, doc_values: false },
|
||||
isTextBasedQuery: { type: 'boolean', index: false, doc_values: false },
|
||||
usesAdHocDataView: { type: 'boolean', index: false, doc_values: false },
|
||||
hideAggregatedPreview: { type: 'boolean', index: false, doc_values: false },
|
||||
hits: { type: 'integer', index: false, doc_values: false },
|
||||
kibanaSavedObjectMeta: {
|
||||
properties: {
|
||||
searchSourceJSON: { type: 'text', index: false },
|
||||
},
|
||||
},
|
||||
sort: { type: 'keyword', index: false, doc_values: false },
|
||||
title: { type: 'text' },
|
||||
grid: { dynamic: false, properties: {} },
|
||||
version: { type: 'integer' },
|
||||
rowHeight: { type: 'text' },
|
||||
timeRestore: { type: 'boolean', index: false, doc_values: false },
|
||||
timeRange: {
|
||||
dynamic: false,
|
||||
properties: {
|
||||
from: { type: 'keyword', index: false, doc_values: false },
|
||||
to: { type: 'keyword', index: false, doc_values: false },
|
||||
},
|
||||
},
|
||||
refreshInterval: {
|
||||
dynamic: false,
|
||||
properties: {
|
||||
pause: { type: 'boolean', index: false, doc_values: false },
|
||||
value: { type: 'integer', index: false, doc_values: false },
|
||||
},
|
||||
},
|
||||
rowsPerPage: { type: 'integer', index: false, doc_values: false },
|
||||
breakdownField: { type: 'text' },
|
||||
description: { type: 'text' },
|
||||
},
|
||||
},
|
||||
schemas: {
|
||||
'8.8.0': schema.object({
|
||||
// General
|
||||
title: schema.string(),
|
||||
description: schema.string({ defaultValue: '' }),
|
||||
|
||||
// Data grid
|
||||
columns: schema.arrayOf(schema.string(), { defaultValue: [] }),
|
||||
sort: schema.oneOf(
|
||||
[
|
||||
schema.arrayOf(schema.arrayOf(schema.string(), { minSize: 2, maxSize: 2 })),
|
||||
schema.arrayOf(schema.string(), { minSize: 2, maxSize: 2 }),
|
||||
],
|
||||
{ defaultValue: [] }
|
||||
),
|
||||
grid: schema.object(
|
||||
{
|
||||
columns: schema.maybe(
|
||||
schema.recordOf(
|
||||
schema.string(),
|
||||
schema.object({
|
||||
width: schema.maybe(schema.number()),
|
||||
})
|
||||
)
|
||||
),
|
||||
},
|
||||
{ defaultValue: {} }
|
||||
),
|
||||
rowHeight: schema.maybe(schema.number()),
|
||||
rowsPerPage: schema.maybe(schema.number()),
|
||||
|
||||
// Chart
|
||||
hideChart: schema.boolean({ defaultValue: false }),
|
||||
breakdownField: schema.maybe(schema.string()),
|
||||
|
||||
// Search
|
||||
kibanaSavedObjectMeta: schema.object({
|
||||
searchSourceJSON: schema.string(),
|
||||
}),
|
||||
isTextBasedQuery: schema.boolean({ defaultValue: false }),
|
||||
usesAdHocDataView: schema.maybe(schema.boolean()),
|
||||
|
||||
// Time
|
||||
timeRestore: schema.maybe(schema.boolean()),
|
||||
timeRange: schema.maybe(
|
||||
schema.object({
|
||||
from: schema.string(),
|
||||
to: schema.string(),
|
||||
})
|
||||
),
|
||||
refreshInterval: schema.maybe(
|
||||
schema.object({
|
||||
pause: schema.boolean(),
|
||||
value: schema.number(),
|
||||
})
|
||||
),
|
||||
|
||||
// Display
|
||||
viewMode: schema.maybe(
|
||||
schema.oneOf([
|
||||
schema.literal(VIEW_MODE.DOCUMENT_LEVEL),
|
||||
schema.literal(VIEW_MODE.AGGREGATED_LEVEL),
|
||||
])
|
||||
),
|
||||
hideAggregatedPreview: schema.maybe(schema.boolean()),
|
||||
|
||||
// Legacy
|
||||
hits: schema.maybe(schema.number()),
|
||||
version: schema.maybe(schema.number()),
|
||||
}),
|
||||
},
|
||||
migrations: () => getAllMigrations(getSearchSourceMigrations()),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"@kbn/spaces-plugin",
|
||||
"@kbn/saved-objects-tagging-oss-plugin",
|
||||
"@kbn/i18n",
|
||||
"@kbn/config-schema",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -33,7 +33,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
'type',
|
||||
'visualization.title',
|
||||
'dashboard.title',
|
||||
'search.columns',
|
||||
'search.title',
|
||||
'space.name',
|
||||
];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue