Skip to content

Commit

Permalink
Update search session saved object mappings (#154401)
Browse files Browse the repository at this point in the history
## Summary

Part of #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.
  • Loading branch information
lukasolson authored Apr 10, 2023
1 parent ee424cb commit 8770a1c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
56 changes: 26 additions & 30 deletions src/plugins/data/server/search/saved_objects/search_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
},
Expand All @@ -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 {
Expand Down

0 comments on commit 8770a1c

Please sign in to comment.