Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const searchSessionRequestInfoSchema = schema.object({
status: schema.maybe(schema.string()),
startedAt: schema.maybe(schema.string()),
completedAt: schema.maybe(schema.string()),
error: schema.maybe(
schema.object({
code: schema.number(),
message: schema.maybe(schema.string()),
})
),
});

const serializeableSchema = schema.mapOf(schema.string(), schema.any());
Expand Down Expand Up @@ -50,7 +56,7 @@ const status = schema.object({
schema.literal('cancelled'),
schema.literal('expired'),
]),
errors: schema.maybe(schema.arrayOf(schema.string())),
errors: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 10000 })),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in theory we can have as many errors as searches in the background search - I'm just going with the elasticsearch default max here

});

export const searchSessionStatusSchema = status;
Expand All @@ -61,12 +67,13 @@ export const searchSessionStatusesSchema = schema.object({

export const searchSessionsFindSchema = schema.object({
total: schema.number(),
saved_objects: schema.arrayOf(searchSessionSchema),
saved_objects: schema.arrayOf(searchSessionSchema, { maxSize: 10000 }),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be the page size for the management page, by default it's 100 but it can be tweaked with data.search.sessions.management.maxSessions

statuses: schema.recordOf(schema.string(), searchSessionStatusSchema),
});

const referencesSchema = schema.arrayOf(
schema.object({ id: schema.string(), type: schema.string(), name: schema.string() })
schema.object({ id: schema.string(), type: schema.string(), name: schema.string() }),
{ maxSize: 10 }
Comment on lines +75 to +76
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this one i'm using a low number just for future proofing because as far as i've seen we don't get references, it's always undefined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this is odd, I wonder if we can remove this altogether. I think this might be a bug. Anyway, not important for this PR.

);

export const searchSessionsUpdateSchema = schema.object({
Expand All @@ -75,7 +82,8 @@ export const searchSessionsUpdateSchema = schema.object({
updated_at: schema.maybe(schema.string()),
updated_by: schema.maybe(schema.string()),
version: schema.maybe(schema.string()),
namespaces: schema.maybe(schema.arrayOf(schema.string())),
// The search-sessions saved object definition specifies that the namespaces are 'single', that means only one space is allowed.
namespaces: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 1 })),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespaces should always be 1 as defined in the saved object definition:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind adding a comment noting that?

references: schema.maybe(referencesSchema),
attributes: schema.object({
name: schema.maybe(schema.string()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function registerSessionRoutes(router: DataPluginRouter, logger: Logger):
schema.oneOf([schema.literal('desc'), schema.literal('asc')])
),
filter: schema.maybe(schema.string()),
searchFields: schema.maybe(schema.arrayOf(schema.string())),
searchFields: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 10 })),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to references i'm going with a low number for future proofing, right now we don't pass down any filter through the _find api so this is not being used

search: schema.maybe(schema.string()),
}),
},
Expand Down Expand Up @@ -412,7 +412,10 @@ export function registerSessionRoutes(router: DataPluginRouter, logger: Logger):
validate: {
request: {
body: schema.object({
sessionIds: schema.arrayOf(schema.string()),
// When a search is sent to the background the client starts polling for its status. All the searches that
// are in progress are sent to the server to get their updated status until they are in a completed status.
// For this endpoint the assumption is that the client won't have more than 100 searches in progress at the same time.
sessionIds: schema.arrayOf(schema.string(), { maxSize: 100 }),
}),
},
response: {
Expand Down
Loading