import { schema } from '@osd/config-schema' ; import { IRouter } from 'src/core/server' ; import { SearchRouteDependencies } from '../search_service' ; import { getCallMsearch } from './call_msearch' ; deprecated export function registerMsearchRoute ( router , deps ) { router . post ( { path : '/internal/_msearch' , validate : { body : schema . object ( { searches : schema . arrayOf ( schema . object ( { header : schema . object ( { index : schema . string ( ) , preference : schema . maybe ( schema . oneOf ( [ schema . number ( ) , schema . string ( ) ] ) ) , } , { unknowns : 'allow' } ) , body : schema . object ( { } , { unknowns : 'allow' } ) , } ) ) , } ) , } , } , async ( context , request , res ) => { const callMsearch = getCallMsearch ( { opensearchClient : context . core . opensearch . client , globalConfig$ : deps . globalConfig$ , uiSettings : context . core . uiSettings . client , } ) ; try { const response = await callMsearch ( { body : request . body } ) ; return res . ok ( response ) ; } catch ( err ) { return res . customError ( { statusCode : err . statusCode || 500 , body : { message : err . message , attributes : { error : err . body ?. error || err . message , } , } , } ) ; } } ) ; }