Skip to content

Commit

Permalink
[Search] Notebooks: add support for remote catalog fetching (#182590)
Browse files Browse the repository at this point in the history
## Summary

This adds a new config item for the `search_notebooks` catalog to allow
fetching it from a URL instead of only serving the static notebooks
packaged with Kibana. This will be used in ES3 to ensure we have the
latest notebooks, but also give us the ability to change which notebooks
are served without making kibana code changes.
  • Loading branch information
TattdCodeMonkey committed May 8, 2024
1 parent 233cc1e commit d770d21
Show file tree
Hide file tree
Showing 10 changed files with 807 additions and 41 deletions.
3 changes: 3 additions & 0 deletions config/serverless.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ data_visualizer.resultLinks.fileBeat.enabled: false

# Search Playground
xpack.searchPlayground.ui.enabled: true

# Search Notebooks
xpack.search.notebooks.catalog.url: https://elastic-enterprise-search.s3.us-east-2.amazonaws.com/serverless/catalog.json
64 changes: 60 additions & 4 deletions x-pack/plugins/search_notebooks/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,77 @@
* 2.0.
*/

import { schema } from '@kbn/config-schema';
import { NotebookDefinition } from '@kbn/ipynb';

export interface NotebookInformation {
id: string;
title: string;
description: string;
link?: {
title: string;
url: string;
};
}
export interface NotebookCatalog {
notebooks: NotebookInformation[];
}

export interface Notebook extends NotebookInformation {
link?: {
title: string;
url: string;
};
notebook: NotebookDefinition;
}

export const NotebookCatalogSchema = schema.object(
{
notebooks: schema.arrayOf(
schema.object(
{
id: schema.string(),
title: schema.string(),
description: schema.string(),
url: schema.uri(),
link: schema.maybe(
schema.object({
title: schema.string(),
url: schema.uri(),
})
),
},
{
unknowns: 'allow',
}
),
{ minSize: 1 }
),
},
{
unknowns: 'allow',
}
);
const NotebookCellSchema = schema.object(
{
attachments: schema.maybe(schema.any()),
auto_number: schema.maybe(schema.number()),
cell_type: schema.maybe(schema.string()),
execution_count: schema.maybe(schema.nullable(schema.number())),
id: schema.maybe(schema.string()),
input: schema.maybe(schema.arrayOf(schema.string())),
metadata: schema.maybe(schema.any()),
outputs: schema.maybe(schema.arrayOf(schema.any())),
prompt_number: schema.maybe(schema.number()),
source: schema.maybe(schema.arrayOf(schema.string())),
},
{
unknowns: 'allow',
}
);

export const NotebookSchema = schema.object(
{
cells: schema.arrayOf(NotebookCellSchema, { minSize: 1 }),
metadata: schema.maybe(schema.any()),
},
{
unknowns: 'allow',
}
);
7 changes: 7 additions & 0 deletions x-pack/plugins/search_notebooks/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ export * from './types';

const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
catalog: schema.maybe(
schema.object({
url: schema.uri(),
ttl: schema.number({ defaultValue: 900 }),
errorTTL: schema.number({ defaultValue: 3600 }),
})
),
});

type SearchNotebooksSchema = TypeOf<typeof configSchema>;
Expand Down

0 comments on commit d770d21

Please sign in to comment.