-
Notifications
You must be signed in to change notification settings - Fork 966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add MDS support for index pattern validate script #9371
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Add MDS support for index pattern validate script ([#9371](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9371)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,18 @@ export function registerPreviewScriptedFieldRoute(router: IRouter): void { | |
query: schema.maybe(schema.object({}, { unknowns: 'allow' })), | ||
additionalFields: schema.maybe(schema.arrayOf(schema.string())), | ||
}), | ||
query: schema.object({ | ||
dataSourceId: schema.maybe(schema.string()), | ||
}), | ||
}, | ||
}, | ||
async (context, request, res) => { | ||
const client = context.core.opensearch.client.asCurrentUser; | ||
const { index, name, script, query, additionalFields } = request.body; | ||
const { dataSourceId } = request.query; | ||
const client = | ||
dataSourceId && context.dataSource | ||
? await context.dataSource.opensearch.getClient(dataSourceId) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to handle the error during There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there may be no need because if the remote client can't be got, it should throw error as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may need to wrap the getClient or the http request may give statusCode of 500. |
||
: context.core.opensearch.client.asCurrentUser; | ||
|
||
try { | ||
const response = await client.search({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use
props.indexPattern.dataSourceRef?.id
? I do not think a dataSourceId state is necessary for this component.