Skip to content

Commit 6ee7111

Browse files
Liza Katzelasticmachine
andauthored
[7.x] [SEARCH] Cleanup fetch soon (elastic#63320) (elastic#63929)
* [SEARCH] Cleanup fetch soon (elastic#63320) * move old code to legacy folder * Use search service directly from search source * Move get search params to fetch folder * Delete search strategy folder * Doc update * Minor cleanups * Moved es client to legacy folder * Clean up some unused code (isViable, old search function) * Updated tests * strings update * Fix jest test * re-arrange runSearch function * re-arrange runSearch function * fix jest tests Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> * remove file (bad merge) Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 8798423 commit 6ee7111

36 files changed

+276
-322
lines changed

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
| [SavedQuery](./kibana-plugin-plugins-data-public.savedquery.md) | |
8989
| [SavedQueryService](./kibana-plugin-plugins-data-public.savedqueryservice.md) | |
9090
| [SearchSourceFields](./kibana-plugin-plugins-data-public.searchsourcefields.md) | |
91-
| [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) | |
9291
| [TabbedAggColumn](./kibana-plugin-plugins-data-public.tabbedaggcolumn.md) | \* |
9392
| [TabbedTable](./kibana-plugin-plugins-data-public.tabbedtable.md) | \* |
9493
| [TimeRange](./kibana-plugin-plugins-data-public.timerange.md) | |

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.id.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.isviable.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.search.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_indices.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { getIndices } from './get_indices';
2121
import { IndexPatternCreationConfig } from '../../../../../../../../../plugins/index_pattern_management/public';
2222
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
23-
import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search';
23+
import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search/legacy';
2424

2525
export const successfulResponse = {
2626
hits: {

src/plugins/data/public/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ export {
363363
SearchRequest,
364364
SearchResponse,
365365
SearchError,
366-
SearchStrategyProvider,
367366
ISearchSource,
368367
SearchSource,
369368
createSearchSource,

src/plugins/data/public/public.api.md

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,21 +1736,6 @@ export interface SearchSourceFields {
17361736
version?: boolean;
17371737
}
17381738

1739-
// Warning: (ae-missing-release-tag) "SearchStrategyProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
1740-
//
1741-
// @public (undocumented)
1742-
export interface SearchStrategyProvider {
1743-
// (undocumented)
1744-
id: string;
1745-
// (undocumented)
1746-
isViable: (indexPattern: IndexPattern) => boolean;
1747-
// Warning: (ae-forgotten-export) The symbol "SearchStrategySearchParams" needs to be exported by the entry point index.d.ts
1748-
// Warning: (ae-forgotten-export) The symbol "SearchStrategyResponse" needs to be exported by the entry point index.d.ts
1749-
//
1750-
// (undocumented)
1751-
search: (params: SearchStrategySearchParams) => SearchStrategyResponse;
1752-
}
1753-
17541739
// Warning: (ae-missing-release-tag) "SortDirection" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
17551740
//
17561741
// @public (undocumented)
@@ -1901,21 +1886,21 @@ export type TSearchStrategyProvider<T extends TStrategyTypes> = (context: ISearc
19011886
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
19021887
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts
19031888
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
1904-
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
1905-
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
1906-
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
1907-
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
1908-
// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
1909-
// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts
1910-
// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
1911-
// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
1912-
// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
1913-
// src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
1914-
// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
1915-
// src/plugins/data/public/index.ts:406:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
1916-
// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
1917-
// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
1918-
// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
1889+
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
1890+
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
1891+
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
1892+
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
1893+
// src/plugins/data/public/index.ts:387:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
1894+
// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts
1895+
// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
1896+
// src/plugins/data/public/index.ts:399:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
1897+
// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
1898+
// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
1899+
// src/plugins/data/public/index.ts:404:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
1900+
// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
1901+
// src/plugins/data/public/index.ts:408:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
1902+
// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
1903+
// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
19191904
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
19201905
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts
19211906
// src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromEvent" needs to be exported by the entry point index.d.ts

src/plugins/data/public/search/aggs/test_helpers/mock_data_services.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919

2020
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
21-
import { coreMock } from '../../../../../../../src/core/public/mocks';
22-
import { dataPluginMock } from '../../../../public/mocks';
21+
import { coreMock } from '../../../../../../core/public/mocks';
22+
import { dataPluginMock } from '../../../mocks';
2323
import {
2424
setFieldFormats,
2525
setIndexPatterns,
@@ -29,7 +29,7 @@ import {
2929
setQueryService,
3030
setSearchService,
3131
setUiSettings,
32-
} from '../../../../public/services';
32+
} from '../../../services';
3333

3434
/**
3535
* Testing helper which calls all of the service setters used in the
@@ -49,4 +49,9 @@ export function mockDataServices() {
4949
setQueryService(data.query);
5050
setSearchService(data.search);
5151
setUiSettings(core.uiSettings);
52+
53+
return {
54+
core,
55+
data,
56+
};
5257
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { getSearchParams } from './get_search_params';
21+
import { IUiSettingsClient } from 'kibana/public';
22+
23+
function getConfigStub(config: any = {}) {
24+
return {
25+
get: key => config[key],
26+
} as IUiSettingsClient;
27+
}
28+
29+
describe('getSearchParams', () => {
30+
test('includes rest_total_hits_as_int', () => {
31+
const config = getConfigStub();
32+
const searchParams = getSearchParams(config);
33+
expect(searchParams.rest_total_hits_as_int).toBe(true);
34+
});
35+
36+
test('includes ignore_unavailable', () => {
37+
const config = getConfigStub();
38+
const searchParams = getSearchParams(config);
39+
expect(searchParams.ignore_unavailable).toBe(true);
40+
});
41+
42+
test('includes ignore_throttled according to search:includeFrozen', () => {
43+
let config = getConfigStub({ 'search:includeFrozen': true });
44+
let searchParams = getSearchParams(config);
45+
expect(searchParams.ignore_throttled).toBe(false);
46+
47+
config = getConfigStub({ 'search:includeFrozen': false });
48+
searchParams = getSearchParams(config);
49+
expect(searchParams.ignore_throttled).toBe(true);
50+
});
51+
52+
test('includes max_concurrent_shard_requests according to courier:maxConcurrentShardRequests', () => {
53+
let config = getConfigStub({ 'courier:maxConcurrentShardRequests': 0 });
54+
let searchParams = getSearchParams(config);
55+
expect(searchParams.max_concurrent_shard_requests).toBe(undefined);
56+
57+
config = getConfigStub({ 'courier:maxConcurrentShardRequests': 5 });
58+
searchParams = getSearchParams(config);
59+
expect(searchParams.max_concurrent_shard_requests).toBe(5);
60+
});
61+
62+
test('includes timeout according to esShardTimeout if greater than 0', () => {
63+
const config = getConfigStub();
64+
let searchParams = getSearchParams(config, 0);
65+
expect(searchParams.timeout).toBe(undefined);
66+
67+
searchParams = getSearchParams(config, 100);
68+
expect(searchParams.timeout).toBe('100ms');
69+
});
70+
});

0 commit comments

Comments
 (0)