{
- timefilter: TimefilterSetup['timefilter'];
+ timefilter: TimefilterContract;
abortController: any;
min: any;
max: any;
diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts
index 6947d985be436..8a8b5d8e0e3ea 100644
--- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts
@@ -70,7 +70,6 @@ export {
IIndexPattern,
IndexPattern,
indexPatterns,
- hasSearchStategyForIndexPattern,
IFieldType,
SearchSource,
ISearchSource,
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/index.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/index.js
index 1a3922dfc2008..5482258e06564 100644
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/index.js
+++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/index.js
@@ -19,7 +19,6 @@
import { DiscoverNoResults } from './no_results';
import { DiscoverUninitialized } from './uninitialized';
-import { DiscoverUnsupportedIndexPattern } from './unsupported_index_pattern';
import { DiscoverHistogram } from './histogram';
import { getAngularModule, wrapInI18nContext } from '../../../kibana_services';
@@ -33,8 +32,4 @@ app.directive('discoverUninitialized', reactDirective =>
reactDirective(wrapInI18nContext(DiscoverUninitialized))
);
-app.directive('discoverUnsupportedIndexPattern', reactDirective =>
- reactDirective(wrapInI18nContext(DiscoverUnsupportedIndexPattern), ['unsupportedType'])
-);
-
app.directive('discoverHistogram', reactDirective => reactDirective(DiscoverHistogram));
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/unsupported_index_pattern.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/unsupported_index_pattern.js
deleted file mode 100644
index 7cf4fd1d14181..0000000000000
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/unsupported_index_pattern.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import React, { Fragment } from 'react';
-import { EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
-import { FormattedMessage } from '@kbn/i18n/react';
-
-export const DiscoverUnsupportedIndexPattern = ({ unsupportedType }) => {
- // This message makes the assumption that X-Pack will support this type, as is the case with
- // rollup index patterns.
- const message = (
-
- );
-
- return (
-
-
-
-
-
-
-
-
-
- );
-};
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html
index 2d44b12989228..2334e33deadba 100644
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html
+++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html
@@ -38,11 +38,6 @@ {{screenTitle}}
-
-
extends IKibanaSearchResponse {
diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts
index 7487f048525bd..7d739103eb2bb 100644
--- a/src/plugins/data/public/index.ts
+++ b/src/plugins/data/public/index.ts
@@ -286,11 +286,7 @@ export {
export {
ES_SEARCH_STRATEGY,
SYNC_SEARCH_STRATEGY,
- defaultSearchStrategy,
- esSearchStrategyProvider,
getEsPreference,
- addSearchStrategy,
- hasSearchStategyForIndexPattern,
getSearchErrorType,
ISearchContext,
TSearchStrategyProvider,
@@ -348,9 +344,7 @@ export {
SavedQuery,
SavedQueryService,
SavedQueryTimeFilter,
- SavedQueryAttributes,
InputTimeRange,
- TimefilterSetup,
TimeHistory,
TimefilterContract,
TimeHistoryContract,
diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md
index c41a4ef531443..48125254ff749 100644
--- a/src/plugins/data/public/public.api.md
+++ b/src/plugins/data/public/public.api.md
@@ -49,11 +49,6 @@ import { UiSettingsParams } from 'src/core/server/types';
import { UnregisterCallback } from 'history';
import { UserProvidedValues } from 'src/core/server/types';
-// Warning: (ae-missing-release-tag) "addSearchStrategy" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export const addSearchStrategy: (searchStrategy: SearchStrategyProvider) => void;
-
// Warning: (ae-forgotten-export) The symbol "DateFormat" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "baseFormattersPublic" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -153,11 +148,6 @@ export interface DataPublicPluginStart {
};
}
-// Warning: (ae-missing-release-tag) "defaultSearchStrategy" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export const defaultSearchStrategy: SearchStrategyProvider;
-
// @public (undocumented)
export enum ES_FIELD_TYPES {
// (undocumented)
@@ -313,11 +303,6 @@ export interface EsQueryConfig {
// @public (undocumented)
export type EsQuerySortValue = Record;
-// Warning: (ae-missing-release-tag) "esSearchStrategyProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export const esSearchStrategyProvider: TSearchStrategyProvider;
-
// Warning: (ae-missing-release-tag) "ExistsFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -488,11 +473,6 @@ export function getSearchErrorType({ message }: Pick): "
// @public (undocumented)
export function getTime(indexPattern: IIndexPattern | undefined, timeRange: TimeRange, forceNow?: Date): import("../..").RangeFilter | undefined;
-// Warning: (ae-missing-release-tag) "hasSearchStategyForIndexPattern" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export const hasSearchStategyForIndexPattern: (indexPattern: IndexPattern) => boolean;
-
// Warning: (ae-missing-release-tag) "IDataPluginServices" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -517,6 +497,8 @@ export interface IDataPluginServices extends Partial {
//
// @public (undocumented)
export interface IEsSearchRequest extends IKibanaSearchRequest {
+ // (undocumented)
+ indexType?: string;
// (undocumented)
params: SearchParams;
}
@@ -1227,28 +1209,14 @@ export interface RefreshInterval {
//
// @public (undocumented)
export interface SavedQuery {
+ // Warning: (ae-forgotten-export) The symbol "SavedQueryAttributes" needs to be exported by the entry point index.d.ts
+ //
// (undocumented)
attributes: SavedQueryAttributes;
// (undocumented)
id: string;
}
-// Warning: (ae-missing-release-tag) "SavedQueryAttributes" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export interface SavedQueryAttributes {
- // (undocumented)
- description: string;
- // (undocumented)
- filters?: Filter[];
- // (undocumented)
- query: Query;
- // (undocumented)
- timefilter?: SavedQueryTimeFilter;
- // (undocumented)
- title: string;
-}
-
// Warning: (ae-missing-release-tag) "SavedQueryService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -1484,14 +1452,6 @@ export const syncQueryStateWithUrl: (query: Pick<{
// @public (undocumented)
export type TimefilterContract = PublicMethodsOf;
-// @public (undocumented)
-export interface TimefilterSetup {
- // (undocumented)
- history: TimeHistoryContract;
- // (undocumented)
- timefilter: TimefilterContract;
-}
-
// Warning: (ae-missing-release-tag) "TimeHistory" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
diff --git a/src/plugins/data/public/query/saved_query/saved_query_service.test.ts b/src/plugins/data/public/query/saved_query/saved_query_service.test.ts
index c983cc4ea8fc5..a86a5b4ed401e 100644
--- a/src/plugins/data/public/query/saved_query/saved_query_service.test.ts
+++ b/src/plugins/data/public/query/saved_query/saved_query_service.test.ts
@@ -18,8 +18,8 @@
*/
import { createSavedQueryService } from './saved_query_service';
-import { SavedQueryAttributes } from '../..';
import { FilterStateStore } from '../../../common';
+import { SavedQueryAttributes } from './types';
const savedQueryAttributes: SavedQueryAttributes = {
title: 'foo',
diff --git a/src/plugins/data/public/search/fetch/call_client.test.ts b/src/plugins/data/public/search/fetch/call_client.test.ts
index 6b43157aab83b..7a99b7c064515 100644
--- a/src/plugins/data/public/search/fetch/call_client.test.ts
+++ b/src/plugins/data/public/search/fetch/call_client.test.ts
@@ -20,60 +20,35 @@
import { callClient } from './call_client';
import { handleResponse } from './handle_response';
import { FetchHandlers } from './types';
-import { SearchRequest } from '../..';
-import { SearchStrategySearchParams } from '../search_strategy';
-
-const mockResponses = [{}, {}];
-const mockAbortFns = [jest.fn(), jest.fn()];
-const mockSearchFns = [
- jest.fn(({ searchRequests }: SearchStrategySearchParams) => ({
- searching: Promise.resolve(Array(searchRequests.length).fill(mockResponses[0])),
- abort: mockAbortFns[0],
- })),
- jest.fn(({ searchRequests }: SearchStrategySearchParams) => ({
- searching: Promise.resolve(Array(searchRequests.length).fill(mockResponses[1])),
- abort: mockAbortFns[1],
- })),
-];
-const mockSearchStrategies = mockSearchFns.map((search, i) => ({ search, id: i }));
+import { SearchStrategySearchParams, defaultSearchStrategy } from '../search_strategy';
+const mockAbortFn = jest.fn();
jest.mock('./handle_response', () => ({
handleResponse: jest.fn((request, response) => response),
}));
-jest.mock('../search_strategy', () => ({
- getSearchStrategyForSearchRequest: (request: SearchRequest) =>
- mockSearchStrategies[request._searchStrategyId],
- getSearchStrategyById: (id: number) => mockSearchStrategies[id],
-}));
+jest.mock('../search_strategy', () => {
+ return {
+ defaultSearchStrategy: {
+ search: jest.fn(({ searchRequests }: SearchStrategySearchParams) => {
+ return {
+ searching: Promise.resolve(
+ searchRequests.map(req => {
+ return {
+ id: req._searchStrategyId,
+ };
+ })
+ ),
+ abort: mockAbortFn,
+ };
+ }),
+ },
+ };
+});
describe('callClient', () => {
beforeEach(() => {
(handleResponse as jest.Mock).mockClear();
- mockAbortFns.forEach(fn => fn.mockClear());
- mockSearchFns.forEach(fn => fn.mockClear());
- });
-
- test('Executes each search strategy with its group of matching requests', () => {
- const searchRequests = [
- { _searchStrategyId: 0 },
- { _searchStrategyId: 1 },
- { _searchStrategyId: 0 },
- { _searchStrategyId: 1 },
- ];
-
- callClient(searchRequests, [], {} as FetchHandlers);
-
- expect(mockSearchFns[0]).toBeCalled();
- expect(mockSearchFns[0].mock.calls[0][0].searchRequests).toEqual([
- searchRequests[0],
- searchRequests[2],
- ]);
- expect(mockSearchFns[1]).toBeCalled();
- expect(mockSearchFns[1].mock.calls[0][0].searchRequests).toEqual([
- searchRequests[1],
- searchRequests[3],
- ]);
});
test('Passes the additional arguments it is given to the search strategy', () => {
@@ -82,8 +57,11 @@ describe('callClient', () => {
callClient(searchRequests, [], args);
- expect(mockSearchFns[0]).toBeCalled();
- expect(mockSearchFns[0].mock.calls[0][0]).toEqual({ searchRequests, ...args });
+ expect(defaultSearchStrategy.search).toBeCalled();
+ expect((defaultSearchStrategy.search as any).mock.calls[0][0]).toEqual({
+ searchRequests,
+ ...args,
+ });
});
test('Returns the responses in the original order', async () => {
@@ -91,7 +69,8 @@ describe('callClient', () => {
const responses = await Promise.all(callClient(searchRequests, [], {} as FetchHandlers));
- expect(responses).toEqual([mockResponses[1], mockResponses[0]]);
+ expect(responses[0]).toEqual({ id: searchRequests[0]._searchStrategyId });
+ expect(responses[1]).toEqual({ id: searchRequests[1]._searchStrategyId });
});
test('Calls handleResponse with each request and response', async () => {
@@ -101,8 +80,12 @@ describe('callClient', () => {
await Promise.all(responses);
expect(handleResponse).toBeCalledTimes(2);
- expect(handleResponse).toBeCalledWith(searchRequests[0], mockResponses[0]);
- expect(handleResponse).toBeCalledWith(searchRequests[1], mockResponses[1]);
+ expect(handleResponse).toBeCalledWith(searchRequests[0], {
+ id: searchRequests[0]._searchStrategyId,
+ });
+ expect(handleResponse).toBeCalledWith(searchRequests[1], {
+ id: searchRequests[1]._searchStrategyId,
+ });
});
test('If passed an abortSignal, calls abort on the strategy if the signal is aborted', () => {
@@ -117,7 +100,7 @@ describe('callClient', () => {
callClient(searchRequests, requestOptions, {} as FetchHandlers);
abortController.abort();
- expect(mockAbortFns[0]).toBeCalled();
- expect(mockAbortFns[1]).not.toBeCalled();
+ expect(mockAbortFn).toBeCalled();
+ // expect(mockAbortFns[1]).not.toBeCalled();
});
});
diff --git a/src/plugins/data/public/search/fetch/call_client.ts b/src/plugins/data/public/search/fetch/call_client.ts
index 6cc58b05ea183..b3c4c682fa60c 100644
--- a/src/plugins/data/public/search/fetch/call_client.ts
+++ b/src/plugins/data/public/search/fetch/call_client.ts
@@ -17,10 +17,9 @@
* under the License.
*/
-import { groupBy } from 'lodash';
import { handleResponse } from './handle_response';
import { FetchOptions, FetchHandlers } from './types';
-import { getSearchStrategyForSearchRequest, getSearchStrategyById } from '../search_strategy';
+import { defaultSearchStrategy } from '../search_strategy';
import { SearchRequest } from '..';
export function callClient(
@@ -34,34 +33,18 @@ export function callClient(
FetchOptions
]> = searchRequests.map((request, i) => [request, requestsOptions[i]]);
const requestOptionsMap = new Map(requestOptionEntries);
-
- // Group the requests by the strategy used to search that specific request
- const searchStrategyMap = groupBy(searchRequests, (request, i) => {
- const searchStrategy = getSearchStrategyForSearchRequest(request, requestsOptions[i]);
- return searchStrategy.id;
- });
-
- // Execute each search strategy with the group of requests, but return the responses in the same
- // order in which they were received. We use a map to correlate the original request with its
- // response.
const requestResponseMap = new Map();
- Object.keys(searchStrategyMap).forEach(searchStrategyId => {
- const searchStrategy = getSearchStrategyById(searchStrategyId);
- const requests = searchStrategyMap[searchStrategyId];
- // There's no way `searchStrategy` could be undefined here because if we didn't get a matching strategy for this ID
- // then an error would have been thrown above
- const { searching, abort } = searchStrategy!.search({
- searchRequests: requests,
- ...fetchHandlers,
- });
+ const { searching, abort } = defaultSearchStrategy.search({
+ searchRequests,
+ ...fetchHandlers,
+ });
- requests.forEach((request, i) => {
- const response = searching.then(results => handleResponse(request, results[i]));
- const { abortSignal = null } = requestOptionsMap.get(request) || {};
- if (abortSignal) abortSignal.addEventListener('abort', abort);
- requestResponseMap.set(request, response);
- });
- }, []);
+ searchRequests.forEach((request, i) => {
+ const response = searching.then(results => handleResponse(request, results[i]));
+ const { abortSignal = null } = requestOptionsMap.get(request) || {};
+ if (abortSignal) abortSignal.addEventListener('abort', abort);
+ requestResponseMap.set(request, response);
+ });
return searchRequests.map(request => requestResponseMap.get(request));
}
diff --git a/src/plugins/data/public/search/index.ts b/src/plugins/data/public/search/index.ts
index 2a54cfe2be785..6ccd90c6a9eff 100644
--- a/src/plugins/data/public/search/index.ts
+++ b/src/plugins/data/public/search/index.ts
@@ -42,14 +42,7 @@ export { IKibanaSearchResponse, IKibanaSearchRequest } from '../../common/search
export { LegacyApiCaller, SearchRequest, SearchResponse } from './es_client';
-export {
- addSearchStrategy,
- hasSearchStategyForIndexPattern,
- defaultSearchStrategy,
- SearchError,
- SearchStrategyProvider,
- getSearchErrorType,
-} from './search_strategy';
+export { SearchError, SearchStrategyProvider, getSearchErrorType } from './search_strategy';
export {
ISearchSource,
diff --git a/src/plugins/data/public/search/search_source/search_source.ts b/src/plugins/data/public/search/search_source/search_source.ts
index 21e5ded6983ac..0c3321f03dabc 100644
--- a/src/plugins/data/public/search/search_source/search_source.ts
+++ b/src/plugins/data/public/search/search_source/search_source.ts
@@ -73,7 +73,7 @@ import _ from 'lodash';
import { normalizeSortRequest } from './normalize_sort_request';
import { filterDocvalueFields } from './filter_docvalue_fields';
import { fieldWildcardFilter } from '../../../../kibana_utils/public';
-import { SearchRequest } from '../..';
+import { IIndexPattern, SearchRequest } from '../..';
import { SearchSourceOptions, SearchSourceFields } from './types';
import { fetchSoon, FetchOptions, RequestFailure } from '../fetch';
@@ -339,11 +339,20 @@ export class SearchSource {
return searchRequest;
}
+ private getIndexType(index: IIndexPattern) {
+ if (this.searchStrategyId) {
+ return this.searchStrategyId === 'default' ? undefined : this.searchStrategyId;
+ } else {
+ return index?.type;
+ }
+ }
+
private flatten() {
const searchRequest = this.mergeProps();
searchRequest.body = searchRequest.body || {};
const { body, index, fields, query, filters, highlightAll } = searchRequest;
+ searchRequest.indexType = this.getIndexType(index);
const computedFields = index ? index.getComputedFields() : {};
diff --git a/src/plugins/data/public/search/search_strategy/default_search_strategy.ts b/src/plugins/data/public/search/search_strategy/default_search_strategy.ts
index 6fcb1e6b3e8d2..2bd88f51587a8 100644
--- a/src/plugins/data/public/search/search_strategy/default_search_strategy.ts
+++ b/src/plugins/data/public/search/search_strategy/default_search_strategy.ts
@@ -74,7 +74,7 @@ function search({
}: SearchStrategySearchParams) {
const abortController = new AbortController();
const searchParams = getSearchParams(config, esShardTimeout);
- const promises = searchRequests.map(({ index, body }) => {
+ const promises = searchRequests.map(({ index, indexType, body }) => {
const params = {
index: index.title || index,
body,
@@ -82,7 +82,7 @@ function search({
};
const { signal } = abortController;
return searchService
- .search({ params }, { signal })
+ .search({ params, indexType }, { signal })
.toPromise()
.then(({ rawResponse }) => rawResponse);
});
diff --git a/src/plugins/data/public/search/search_strategy/index.ts b/src/plugins/data/public/search/search_strategy/index.ts
index 330e10d7d30e4..e3de2ea46e3ec 100644
--- a/src/plugins/data/public/search/search_strategy/index.ts
+++ b/src/plugins/data/public/search/search_strategy/index.ts
@@ -17,13 +17,6 @@
* under the License.
*/
-export {
- addSearchStrategy,
- hasSearchStategyForIndexPattern,
- getSearchStrategyById,
- getSearchStrategyForSearchRequest,
-} from './search_strategy_registry';
-
export { SearchError, getSearchErrorType } from './search_error';
export { SearchStrategyProvider, SearchStrategySearchParams } from './types';
diff --git a/src/plugins/data/public/search/search_strategy/search_strategy_registry.test.ts b/src/plugins/data/public/search/search_strategy/search_strategy_registry.test.ts
deleted file mode 100644
index eaf86e1b270d5..0000000000000
--- a/src/plugins/data/public/search/search_strategy/search_strategy_registry.test.ts
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { IndexPattern } from '../..';
-import { noOpSearchStrategy } from './no_op_search_strategy';
-import {
- searchStrategies,
- addSearchStrategy,
- getSearchStrategyByViability,
- getSearchStrategyById,
- getSearchStrategyForSearchRequest,
- hasSearchStategyForIndexPattern,
-} from './search_strategy_registry';
-import { SearchStrategyProvider } from './types';
-
-const mockSearchStrategies: SearchStrategyProvider[] = [
- {
- id: '0',
- isViable: (index: IndexPattern) => index.id === '0',
- search: () => ({
- searching: Promise.resolve([]),
- abort: () => void 0,
- }),
- },
- {
- id: '1',
- isViable: (index: IndexPattern) => index.id === '1',
- search: () => ({
- searching: Promise.resolve([]),
- abort: () => void 0,
- }),
- },
-];
-
-describe('Search strategy registry', () => {
- beforeEach(() => {
- searchStrategies.length = 0;
- });
-
- describe('addSearchStrategy', () => {
- it('adds a search strategy', () => {
- addSearchStrategy(mockSearchStrategies[0]);
- expect(searchStrategies.length).toBe(1);
- });
-
- it('does not add a search strategy if it is already included', () => {
- addSearchStrategy(mockSearchStrategies[0]);
- addSearchStrategy(mockSearchStrategies[0]);
- expect(searchStrategies.length).toBe(1);
- });
- });
-
- describe('getSearchStrategyByViability', () => {
- beforeEach(() => {
- mockSearchStrategies.forEach(addSearchStrategy);
- });
-
- it('returns the viable strategy', () => {
- expect(getSearchStrategyByViability({ id: '0' } as IndexPattern)).toBe(
- mockSearchStrategies[0]
- );
- expect(getSearchStrategyByViability({ id: '1' } as IndexPattern)).toBe(
- mockSearchStrategies[1]
- );
- });
-
- it('returns undefined if there is no viable strategy', () => {
- expect(getSearchStrategyByViability({ id: '-1' } as IndexPattern)).toBe(undefined);
- });
- });
-
- describe('getSearchStrategyById', () => {
- beforeEach(() => {
- mockSearchStrategies.forEach(addSearchStrategy);
- });
-
- it('returns the strategy by ID', () => {
- expect(getSearchStrategyById('0')).toBe(mockSearchStrategies[0]);
- expect(getSearchStrategyById('1')).toBe(mockSearchStrategies[1]);
- });
-
- it('returns undefined if there is no strategy with that ID', () => {
- expect(getSearchStrategyById('-1')).toBe(undefined);
- });
-
- it('returns the noOp search strategy if passed that ID', () => {
- expect(getSearchStrategyById('noOp')).toBe(noOpSearchStrategy);
- });
- });
-
- describe('getSearchStrategyForSearchRequest', () => {
- beforeEach(() => {
- mockSearchStrategies.forEach(addSearchStrategy);
- });
-
- it('returns the strategy by ID if provided', () => {
- expect(getSearchStrategyForSearchRequest({}, { searchStrategyId: '1' })).toBe(
- mockSearchStrategies[1]
- );
- });
-
- it('throws if there is no strategy by provided ID', () => {
- expect(() =>
- getSearchStrategyForSearchRequest({}, { searchStrategyId: '-1' })
- ).toThrowErrorMatchingInlineSnapshot(`"No strategy with ID -1"`);
- });
-
- it('returns the strategy by viability if there is one', () => {
- expect(
- getSearchStrategyForSearchRequest({
- index: {
- id: '1',
- },
- })
- ).toBe(mockSearchStrategies[1]);
- });
-
- it('returns the no op strategy if there is no viable strategy', () => {
- expect(getSearchStrategyForSearchRequest({ index: '3' })).toBe(noOpSearchStrategy);
- });
- });
-
- describe('hasSearchStategyForIndexPattern', () => {
- beforeEach(() => {
- mockSearchStrategies.forEach(addSearchStrategy);
- });
-
- it('returns whether there is a search strategy for this index pattern', () => {
- expect(hasSearchStategyForIndexPattern({ id: '0' } as IndexPattern)).toBe(true);
- expect(hasSearchStategyForIndexPattern({ id: '-1' } as IndexPattern)).toBe(false);
- });
- });
-});
diff --git a/src/plugins/data/public/search/search_strategy/search_strategy_registry.ts b/src/plugins/data/public/search/search_strategy/search_strategy_registry.ts
deleted file mode 100644
index 1ab6f7d4e1eff..0000000000000
--- a/src/plugins/data/public/search/search_strategy/search_strategy_registry.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { IndexPattern } from '../..';
-import { SearchStrategyProvider } from './types';
-import { noOpSearchStrategy } from './no_op_search_strategy';
-import { SearchResponse } from '..';
-
-export const searchStrategies: SearchStrategyProvider[] = [];
-
-export const addSearchStrategy = (searchStrategy: SearchStrategyProvider) => {
- if (searchStrategies.includes(searchStrategy)) {
- return;
- }
-
- searchStrategies.push(searchStrategy);
-};
-
-export const getSearchStrategyByViability = (indexPattern: IndexPattern) => {
- return searchStrategies.find(searchStrategy => {
- return searchStrategy.isViable(indexPattern);
- });
-};
-
-export const getSearchStrategyById = (searchStrategyId: string) => {
- return [...searchStrategies, noOpSearchStrategy].find(searchStrategy => {
- return searchStrategy.id === searchStrategyId;
- });
-};
-
-export const getSearchStrategyForSearchRequest = (
- searchRequest: SearchResponse,
- { searchStrategyId }: { searchStrategyId?: string } = {}
-) => {
- // Allow the searchSource to declare the correct strategy with which to execute its searches.
- if (searchStrategyId != null) {
- const strategy = getSearchStrategyById(searchStrategyId);
- if (!strategy) throw Error(`No strategy with ID ${searchStrategyId}`);
- return strategy;
- }
-
- // Otherwise try to match it to a strategy.
- const viableSearchStrategy = getSearchStrategyByViability(searchRequest.index);
-
- if (viableSearchStrategy) {
- return viableSearchStrategy;
- }
-
- // This search strategy automatically rejects with an error.
- return noOpSearchStrategy;
-};
-
-export const hasSearchStategyForIndexPattern = (indexPattern: IndexPattern) => {
- return Boolean(getSearchStrategyByViability(indexPattern));
-};
diff --git a/src/plugins/data/public/ui/saved_query_form/save_query_form.tsx b/src/plugins/data/public/ui/saved_query_form/save_query_form.tsx
index 7183f14bdb255..36dcd4a00c05e 100644
--- a/src/plugins/data/public/ui/saved_query_form/save_query_form.tsx
+++ b/src/plugins/data/public/ui/saved_query_form/save_query_form.tsx
@@ -35,7 +35,8 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { sortBy, isEqual } from 'lodash';
-import { SavedQuery, SavedQueryAttributes, SavedQueryService } from '../..';
+import { SavedQuery, SavedQueryService } from '../..';
+import { SavedQueryAttributes } from '../../query';
interface Props {
savedQuery?: SavedQueryAttributes;
diff --git a/src/plugins/data/server/search/es_search/es_search_strategy.ts b/src/plugins/data/server/search/es_search/es_search_strategy.ts
index 26055a3ae41f7..b4ee02eefaf84 100644
--- a/src/plugins/data/server/search/es_search/es_search_strategy.ts
+++ b/src/plugins/data/server/search/es_search/es_search_strategy.ts
@@ -31,6 +31,13 @@ export const esSearchStrategyProvider: TSearchStrategyProvider {
const config = await context.config$.pipe(first()).toPromise();
const defaultParams = getDefaultSearchParams(config);
+
+ // Only default index pattern type is supported here.
+ // See data_enhanced for other type support.
+ if (!!request.indexType) {
+ throw new Error(`Unsupported index pattern type ${request.indexType}`);
+ }
+
const params = {
...defaultParams,
...request.params,
diff --git a/src/plugins/data/server/search/routes.ts b/src/plugins/data/server/search/routes.ts
index 2b8c4b95ee022..e618f99084aed 100644
--- a/src/plugins/data/server/search/routes.ts
+++ b/src/plugins/data/server/search/routes.ts
@@ -43,11 +43,11 @@ export function registerSearchRoute(router: IRouter): void {
return res.ok({ body: response });
} catch (err) {
return res.customError({
- statusCode: err.statusCode,
+ statusCode: err.statusCode || 500,
body: {
message: err.message,
attributes: {
- error: err.body.error,
+ error: err.body?.error || err.message,
},
},
});
diff --git a/x-pack/legacy/plugins/ml/public/application/util/dependency_cache.ts b/x-pack/legacy/plugins/ml/public/application/util/dependency_cache.ts
index 2a1ffe79d033c..6982d3d2dba97 100644
--- a/x-pack/legacy/plugins/ml/public/application/util/dependency_cache.ts
+++ b/x-pack/legacy/plugins/ml/public/application/util/dependency_cache.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { TimefilterSetup } from 'src/plugins/data/public';
+import { DataPublicPluginSetup } from 'src/plugins/data/public';
import {
IUiSettingsClient,
ChromeStart,
@@ -23,7 +23,7 @@ import {
import { SecurityPluginSetup } from '../../../../../../plugins/security/public';
export interface DependencyCache {
- timefilter: TimefilterSetup | null;
+ timefilter: DataPublicPluginSetup['query']['timefilter'] | null;
config: IUiSettingsClient | null;
indexPatterns: IndexPatternsContract | null;
chrome: ChromeStart | null;
diff --git a/x-pack/legacy/plugins/rollup/public/legacy.ts b/x-pack/legacy/plugins/rollup/public/legacy.ts
index e3e663ac7b0f4..e137799bd34fe 100644
--- a/x-pack/legacy/plugins/rollup/public/legacy.ts
+++ b/x-pack/legacy/plugins/rollup/public/legacy.ts
@@ -7,7 +7,6 @@
import { npSetup, npStart } from 'ui/new_platform';
import { aggTypeFilters } from 'ui/agg_types';
import { aggTypeFieldFilters } from 'ui/agg_types';
-import { addSearchStrategy } from '../../../../../src/plugins/data/public';
import { RollupPlugin } from './plugin';
import { setup as management } from '../../../../../src/legacy/core_plugins/management/public/legacy';
@@ -18,7 +17,6 @@ export const setup = plugin.setup(npSetup.core, {
__LEGACY: {
aggTypeFilters,
aggTypeFieldFilters,
- addSearchStrategy,
managementLegacy: management,
},
});
diff --git a/x-pack/legacy/plugins/rollup/public/plugin.ts b/x-pack/legacy/plugins/rollup/public/plugin.ts
index a01383f4733ef..2d2ff4c8449d8 100644
--- a/x-pack/legacy/plugins/rollup/public/plugin.ts
+++ b/x-pack/legacy/plugins/rollup/public/plugin.ts
@@ -7,14 +7,12 @@
import { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { AggTypeFilters, AggTypeFieldFilters } from './legacy_imports';
-import { SearchStrategyProvider } from '../../../../../src/plugins/data/public';
import { ManagementSetup as ManagementSetupLegacy } from '../../../../../src/legacy/core_plugins/management/public/np_ready';
import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management';
// @ts-ignore
import { RollupIndexPatternCreationConfig } from './index_pattern_creation/rollup_index_pattern_creation_config';
// @ts-ignore
import { RollupIndexPatternListConfig } from './index_pattern_list/rollup_index_pattern_list_config';
-import { getRollupSearchStrategy } from './search/rollup_search_strategy';
// @ts-ignore
import { initAggTypeFilter } from './visualize/agg_type_filter';
// @ts-ignore
@@ -37,7 +35,6 @@ export interface RollupPluginSetupDependencies {
__LEGACY: {
aggTypeFilters: AggTypeFilters;
aggTypeFieldFilters: AggTypeFieldFilters;
- addSearchStrategy: (searchStrategy: SearchStrategyProvider) => void;
managementLegacy: ManagementSetupLegacy;
};
home?: HomePublicPluginSetup;
@@ -49,7 +46,7 @@ export class RollupPlugin implements Plugin {
setup(
core: CoreSetup,
{
- __LEGACY: { aggTypeFilters, aggTypeFieldFilters, addSearchStrategy, managementLegacy },
+ __LEGACY: { aggTypeFilters, aggTypeFieldFilters, managementLegacy },
home,
management,
indexManagement,
@@ -67,7 +64,6 @@ export class RollupPlugin implements Plugin {
if (isRollupIndexPatternsEnabled) {
managementLegacy.indexPattern.creation.add(RollupIndexPatternCreationConfig);
managementLegacy.indexPattern.list.add(RollupIndexPatternListConfig);
- addSearchStrategy(getRollupSearchStrategy(core.http.fetch));
initAggTypeFilter(aggTypeFilters);
initAggTypeFieldFilter(aggTypeFieldFilters);
}
diff --git a/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts b/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts
index 6e12ffb6404c6..69b357196dc32 100644
--- a/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts
+++ b/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts
@@ -30,7 +30,7 @@ export const enhancedEsSearchStrategyProvider: TSearchStrategyProvider;
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index b64caea05dbe4..5b55ad3433e22 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -1116,7 +1116,6 @@
"kbn.discover.noResults.indexFailureIndexText": "インデックス {failureIndex}",
"kbn.discover.noResults.indexFailureShardText": "{index}、シャード {failureShard}",
"kbn.discover.noResults.queryMayNotMatchTitle": "表示されているインデックスの 1 つまたは複数にデータフィールドが含まれています。クエリが現在の時間範囲のデータと一致しないか、現在選択された時間範囲にデータが全く存在しない可能性があります。データが存在する時間範囲に変えることができます。",
- "kbn.discover.noResults.requiredPluginIsNotInstalledOrDisabledTitle": "{unsupportedType} インデックスに基づくインデックスパターンには X-Pack の {unsupportedType} プラグインが必要で、このプラグインは現在インストールされていないか無効になっています。",
"kbn.discover.noResults.searchExamples.400to499StatusCodeExampleTitle": "400-499 のすべてのステータスコードを検索",
"kbn.discover.noResults.searchExamples.400to499StatusCodeWithPhpExtensionExampleTitle": "400-499 の php 拡張子のステータスコードを検索",
"kbn.discover.noResults.searchExamples.400to499StatusCodeWithPhpOrHtmlExtensionExampleTitle": "400-499 の php または html 拡張子のステータスコードを検索",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 872ec3b71ec10..2bf6d0db04a80 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -1116,7 +1116,6 @@
"kbn.discover.noResults.indexFailureIndexText": "索引 {failureIndex}",
"kbn.discover.noResults.indexFailureShardText": "{index},分片 {failureShard}",
"kbn.discover.noResults.queryMayNotMatchTitle": "您正在查看的一个或多个索引包含日期字段。您的查询在当前时间范围内可能不匹配任何数据,也可能在当前选定的时间范围内没有任何数据。您可以尝试将时间范围更改为包含数据的时间范围。",
- "kbn.discover.noResults.requiredPluginIsNotInstalledOrDisabledTitle": "基于 {unsupportedType} 索引的索引模式需要 X-Pack 的 {unsupportedType} 插件,但其未安装或已禁用",
"kbn.discover.noResults.searchExamples.400to499StatusCodeExampleTitle": "查找所有介于 400-499 之间的状态代码",
"kbn.discover.noResults.searchExamples.400to499StatusCodeWithPhpExtensionExampleTitle": "查找状态代码 400-499 以及扩展名 php",
"kbn.discover.noResults.searchExamples.400to499StatusCodeWithPhpOrHtmlExtensionExampleTitle": "查找状态代码 400-499 以及扩展名 php 或 html",