mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Enterprise Search] [Search preview] Update route to support search functionality in preview page (#153965)
## Summary This PR adds `request.body` and `index` to search passthrough kibana route to support search functionality in Search preview page
This commit is contained in:
parent
95253d7cc0
commit
6208a56adb
2 changed files with 7 additions and 12 deletions
|
@ -333,9 +333,7 @@ describe('engines routes', () => {
|
|||
let mockRouter: MockRouter;
|
||||
const mockClient = {
|
||||
asCurrentUser: {
|
||||
transport: {
|
||||
request: jest.fn(),
|
||||
},
|
||||
search: jest.fn(),
|
||||
},
|
||||
};
|
||||
beforeEach(() => {
|
||||
|
@ -356,7 +354,7 @@ describe('engines routes', () => {
|
|||
});
|
||||
});
|
||||
it('POST - Search preview API creates a request', async () => {
|
||||
mockClient.asCurrentUser.transport.request.mockImplementation(() => ({
|
||||
mockClient.asCurrentUser.search.mockImplementation(() => ({
|
||||
acknowledged: true,
|
||||
}));
|
||||
|
||||
|
@ -365,10 +363,8 @@ describe('engines routes', () => {
|
|||
engine_name: 'engine-name',
|
||||
},
|
||||
});
|
||||
expect(mockClient.asCurrentUser.transport.request).toHaveBeenCalledWith({
|
||||
body: {},
|
||||
method: 'POST',
|
||||
path: '/engine-name/_search',
|
||||
expect(mockClient.asCurrentUser.search).toHaveBeenCalledWith({
|
||||
index: 'engine-name',
|
||||
});
|
||||
expect(mockRouter.response.ok).toHaveBeenCalledWith({
|
||||
body: {
|
||||
|
|
|
@ -132,10 +132,9 @@ export function registerEnginesRoutes({ log, router }: RouteDependencies) {
|
|||
},
|
||||
elasticsearchErrorHandler(log, async (context, request, response) => {
|
||||
const { client } = (await context.core).elasticsearch;
|
||||
const engines = await client.asCurrentUser.transport.request<SearchResponse>({
|
||||
body: {},
|
||||
method: 'POST',
|
||||
path: `/${request.params.engine_name}/_search`,
|
||||
const engines = await client.asCurrentUser.search<SearchResponse>({
|
||||
index: request.params.engine_name,
|
||||
...request.body,
|
||||
});
|
||||
return response.ok({ body: engines });
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue