Update search session saved object mappings (#154401)

## Summary

Part of https://github.com/elastic/kibana/pull/153070.

Cleans up the saved object mappings for search session saved objects.
Removes the non-searchable/sortable properties from the `mappings`
property and introduces a `schema` property for validation.
This commit is contained in:
Lukas Olson 2023-04-10 14:52:43 -07:00 committed by GitHub
parent ee424cb3ad
commit 8770a1ceed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 31 deletions

View file

@ -126,7 +126,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"rules-settings": "9854495c3b54b16a6625fb250c35e5504da72266",
"sample-data-telemetry": "c38daf1a49ed24f2a4fb091e6e1e833fccf19935",
"search": "ed3a9b1681b57d69560909d51933fdf17576ea68",
"search-session": "58a44d14ec991739166b2ec28d718001ab0f4b28",
"search-session": "fae0dfc63274d6a3b90ca583802c48cab8760637",
"search-telemetry": "1bbaf2db531b97fa04399440fa52d46e86d54dd8",
"security-rule": "1ff82dfb2298c3caf6888fc3ef15c6bf7a628877",
"security-solution-signals-migration": "c2db409c1857d330beb3d6fd188fa186f920302c",

View file

@ -6,6 +6,7 @@
* Side Public License, v 1.
*/
import { schema } from '@kbn/config-schema';
import { SavedObjectsType } from '@kbn/core/server';
import { SEARCH_SESSION_TYPE } from '../../../common';
import { searchSessionSavedObjectMigrations } from './search_session_migration';
@ -15,37 +16,14 @@ export const searchSessionSavedObjectType: SavedObjectsType = {
namespaceType: 'single',
hidden: true,
mappings: {
dynamic: false,
properties: {
sessionId: {
type: 'keyword',
},
name: {
type: 'keyword',
},
created: {
type: 'date',
},
expires: {
type: 'date',
},
appId: {
type: 'keyword',
},
locatorId: {
type: 'keyword',
},
initialState: {
dynamic: false,
properties: {},
},
restoreState: {
dynamic: false,
properties: {},
},
idMapping: {
dynamic: false,
properties: {},
},
realmType: {
type: 'keyword',
},
@ -55,14 +33,32 @@ export const searchSessionSavedObjectType: SavedObjectsType = {
username: {
type: 'keyword',
},
version: {
type: 'keyword',
},
isCanceled: {
type: 'boolean',
},
},
},
schemas: {
'8.8.0': schema.object({
sessionId: schema.string(),
name: schema.maybe(schema.string()),
created: schema.string(),
expires: schema.string(),
appId: schema.maybe(schema.string()),
locatorId: schema.maybe(schema.string()),
initialState: schema.maybe(schema.object({}, { unknowns: 'allow' })),
restoreState: schema.maybe(schema.object({}, { unknowns: 'allow' })),
idMapping: schema.mapOf(
schema.string(),
schema.object({
id: schema.string(),
strategy: schema.string(),
})
),
realmType: schema.maybe(schema.string()),
realmName: schema.maybe(schema.string()),
username: schema.maybe(schema.string()),
version: schema.string(),
isCanceled: schema.maybe(schema.boolean()),
}),
},
migrations: searchSessionSavedObjectMigrations,
excludeOnUpgrade: async () => {
return {