-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Content Management] Cross Type Search (
savedObjects.find()
based) (#…
…154464) ## Summary Partially addresses #152224 [Tech Doc (private)](https://docs.google.com/document/d/1ssYmqSEUPrsuCR4iz8DohkEWekoYrm2yL4QR_fVxXLg/edit#heading=h.6sj4n6bjcgp5) Introduce `mSearch` - temporary cross-content type search layer for content management backed by `savedObjects.find` Until we have [a dedicated search layer in CM services](https://docs.google.com/document/d/1mTa1xJIr8ttRnhkHcbdyLSpNJDL1FPJ3OyK4xnOsmnQ/edit), we want to provide a temporary solution to replace client-side or naive server proxy usages of `savedObjects.find()` across multiple types with Content Management API to prepare these places for backward compatibility compliance. Later we plan to use the new API together with shared components that work across multiple types like `SavedObjectFinder` or `TableListView` The api would only work with content types that use saved objects as a backend. To opt-in a saved object backed content type to `mSearch` need to provide `MSearchConfig` on `ContentStorage`: ``` export class MapsStorage implements ContentStorage<Map> { // ... mSearch: { savedObjectType: 'maps', toItemResult: (ctx: StorageContext, mapsSavedObject: SavedObject<MapsAttributes>) => toMap(ctx,mapsSavedObject), // transform, validate, version additionalSearchFields: ['something-maps-specific'], } } ``` *Out of scope of this PR:* - tags search (will follow up shortly) - pagination (as described in [the doc]([Tech Doc](https://docs.google.com/document/d/1ssYmqSEUPrsuCR4iz8DohkEWekoYrm2yL4QR_fVxXLg/edit#heading=h.6sj4n6bjcgp5)) server-side pagination is not needed for the first consumers, but will follow up shortly) - end-to-end / integration testing (don't want to introduce a dummy saved object for testing this, instead plan to wait for maps CM onboard and test using maps #153304) - Documentation (will add into #154453) - Add rxjs and hook method
- Loading branch information
Showing
24 changed files
with
715 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import { schema } from '@kbn/config-schema'; | ||
import type { Version } from '@kbn/object-versioning'; | ||
import { versionSchema } from './constants'; | ||
import { searchQuerySchema, searchResultSchema, SearchQuery, SearchResult } from './search'; | ||
|
||
import type { ProcedureSchemas } from './types'; | ||
|
||
export const mSearchSchemas: ProcedureSchemas = { | ||
in: schema.object( | ||
{ | ||
contentTypes: schema.arrayOf( | ||
schema.object({ contentTypeId: schema.string(), version: versionSchema }), | ||
{ | ||
minSize: 1, | ||
} | ||
), | ||
query: searchQuerySchema, | ||
}, | ||
{ unknowns: 'forbid' } | ||
), | ||
out: schema.object( | ||
{ | ||
contentTypes: schema.arrayOf( | ||
schema.object({ contentTypeId: schema.string(), version: versionSchema }) | ||
), | ||
result: searchResultSchema, | ||
}, | ||
{ unknowns: 'forbid' } | ||
), | ||
}; | ||
|
||
export type MSearchQuery = SearchQuery; | ||
|
||
export interface MSearchIn { | ||
contentTypes: Array<{ contentTypeId: string; version?: Version }>; | ||
query: MSearchQuery; | ||
} | ||
|
||
export type MSearchResult<T = unknown> = SearchResult<T>; | ||
|
||
export interface MSearchOut<T = unknown> { | ||
contentTypes: Array<{ contentTypeId: string; version?: Version }>; | ||
result: MSearchResult<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.