Skip to content

Commit

Permalink
Remove old search code and rename UI Setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Nov 17, 2020
1 parent 3de838c commit 17de9fa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 190 deletions.
20 changes: 3 additions & 17 deletions src/plugins/data/public/search/search_interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { get, memoize, trimEnd } from 'lodash';
import { get, memoize } from 'lodash';
import { BehaviorSubject, throwError, timer, defer, from, Observable, NEVER } from 'rxjs';
import { catchError, finalize } from 'rxjs/operators';
import { PublicMethodsOf } from '@kbn/utility-types';
Expand All @@ -29,7 +29,6 @@ import {
IKibanaSearchResponse,
ISearchOptions,
ISessionService,
ES_SEARCH_STRATEGY,
} from '../../common';
import { SearchUsageCollector } from './collectors';
import {
Expand Down Expand Up @@ -71,7 +70,7 @@ export class SearchInterceptor {
* @internal
*/
protected application!: CoreStart['application'];
private batchedFetch?: BatchedFunc<
private batchedFetch!: BatchedFunc<
{ request: IKibanaSearchRequest; strategy?: string },
IKibanaSearchResponse
>;
Expand Down Expand Up @@ -139,20 +138,7 @@ export class SearchInterceptor {
signal: AbortSignal,
strategy?: string
): Promise<IKibanaSearchResponse> {
if (this.batchedFetch) {
return this.batchedFetch({ request, strategy }, signal);
} else {
const { id, ...searchRequest } = request;
const path = trimEnd(`/internal/search/${strategy || ES_SEARCH_STRATEGY}/${id || ''}`, '/');
const body = JSON.stringify(searchRequest);

return this.deps.http.fetch({
method: 'POST',
path,
body,
signal,
});
}
return this.batchedFetch({ request, strategy }, signal);
}

/**
Expand Down
119 changes: 0 additions & 119 deletions src/plugins/data/server/search/routes/search.test.ts

This file was deleted.

50 changes: 0 additions & 50 deletions src/plugins/data/server/search/routes/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,60 +17,10 @@
* under the License.
*/

import { first } from 'rxjs/operators';
import { schema } from '@kbn/config-schema';
import type { IRouter } from 'src/core/server';
import { getRequestAbortedSignal } from '../../lib';

export function registerSearchRoute(router: IRouter): void {
router.post(
{
path: '/internal/search/{strategy}/{id?}',
validate: {
params: schema.object({
strategy: schema.string(),
id: schema.maybe(schema.string()),
}),

query: schema.object({}, { unknowns: 'allow' }),

body: schema.object({}, { unknowns: 'allow' }),
},
},
async (context, request, res) => {
const searchRequest = request.body;
const { strategy, id } = request.params;
const abortSignal = getRequestAbortedSignal(request.events.aborted$);

try {
const response = await context
.search!.search(
{ ...searchRequest, id },
{
abortSignal,
strategy,
}
)
.pipe(first())
.toPromise();

return res.ok({
body: response,
});
} catch (err) {
return res.customError({
statusCode: err.statusCode || 500,
body: {
message: err.message,
attributes: {
error: err.body?.error || err.message,
},
},
});
}
}
);

router.delete(
{
path: '/internal/search/{strategy}/{id}',
Expand Down
7 changes: 3 additions & 4 deletions src/plugins/data/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,13 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
},
[UI_SETTINGS.COURIER_BATCH_SEARCHES]: {
name: i18n.translate('data.advancedSettings.courier.batchSearchesTitle', {
defaultMessage: 'Batch concurrent searches',
defaultMessage: 'Use legacy search',
}),
value: false,
type: 'boolean',
description: i18n.translate('data.advancedSettings.courier.batchSearchesText', {
defaultMessage: `When disabled, dashboard panels will load individually, and search requests will terminate when users navigate
away or update the query. When enabled, dashboard panels will load together when all of the data is loaded, and
searches will not terminate.`,
defaultMessage: `Kibana uses a new search and batching infrastructure.
Enable this option if you prefer to fallback to the legacy synchronous behavior`,
}),
deprecation: {
message: i18n.translate('data.advancedSettings.courier.batchSearchesTextDeprecation', {
Expand Down

0 comments on commit 17de9fa

Please sign in to comment.