Skip to content

Commit f5c6882

Browse files
committed
data.search body removals
1 parent 0818c90 commit f5c6882

File tree

13 files changed

+49
-59
lines changed

13 files changed

+49
-59
lines changed

examples/search_examples/public/search/app.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,15 @@ export const SearchExamplesApp = ({
181181
const aggs = [{ type: metricAggType, params: { field: selectedNumericField!.name } }];
182182
const aggsDsl = data.search.aggs.createAggConfigs(dataView, aggs).toDsl();
183183

184+
const body = {
185+
aggs: aggsDsl,
186+
query,
187+
};
188+
184189
const req = {
185190
params: {
186191
index: dataView.title,
187-
body: {
188-
aggs: aggsDsl,
189-
query,
190-
},
192+
...body,
191193
},
192194
// Add a custom request parameter to be consumed by `MyStrategy`.
193195
...(strategy ? { get_cool: getCool } : {}),
@@ -197,7 +199,7 @@ export const SearchExamplesApp = ({
197199
setAbortController(abortController);
198200

199201
// Submit the search request using the `data.search` service.
200-
setRequest(req.params.body);
202+
setRequest(body);
201203
setRawResponse({});
202204
setWarningContents([]);
203205
setIsLoading(true);

examples/unified_doc_viewer/public/application.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ function UnifiedDocViewerExamplesApp({ data }: { data: DataPublicPluginStart })
4444
.search({
4545
params: {
4646
index: dataView?.getIndexPattern(),
47-
body: {
48-
fields: ['*'],
49-
_source: false,
50-
},
47+
fields: ['*'],
48+
_source: false,
5149
},
5250
})
5351
.toPromise();

packages/kbn-es-archiver/src/lib/indices/kibana_index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export async function createDefaultSpace({ index, client }: { index: string; cli
166166
index,
167167
id: 'space:default',
168168
refresh: 'wait_for',
169-
body: {
169+
document: {
170170
type: 'space',
171171
updated_at: new Date().toISOString(),
172172
space: {

packages/kbn-es/src/utils/native_realm.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ exports.NativeRealm = class NativeRealm {
2727
await this._client.security.changePassword({
2828
username,
2929
refresh: 'wait_for',
30-
body: {
31-
password,
32-
},
30+
password,
3331
});
3432
} catch (err) {
3533
const isAnonymousUserPasswordChangeError =

packages/kbn-es/src/utils/native_realm.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe('setPassword', () => {
204204
it('sets password for provided user', async () => {
205205
await nativeRealm.setPassword('kibana_system', 'foo');
206206
expect(mockClient.security.changePassword).toHaveBeenCalledWith({
207-
body: { password: 'foo' },
207+
password: 'foo',
208208
refresh: 'wait_for',
209209
username: 'kibana_system',
210210
});

src/platform/packages/private/kbn-generate-csv/src/lib/search_cursor_pit.test.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ describe('CSV Export Search Cursor', () => {
101101
expect(dataSearchSpy).toBeCalledTimes(1);
102102
expect(dataSearchSpy).toBeCalledWith(
103103
{
104-
params: {
105-
body: expect.objectContaining({ pit: { id: 'somewhat-pit-id', keep_alive: '10m' } }),
104+
params: expect.objectContaining({
105+
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
106106
max_concurrent_shard_requests: 5,
107-
},
107+
}),
108108
},
109109
expect.objectContaining({
110110
strategy: 'es',
@@ -160,14 +160,12 @@ describe('CSV Export Search Cursor', () => {
160160
expect(dataSearchSpy).toBeCalledWith(
161161
{
162162
params: {
163-
body: {
164-
fields: [],
165-
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
166-
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
167-
runtime_mappings: {},
168-
script_fields: {},
169-
stored_fields: ['*'],
170-
},
163+
fields: [],
164+
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
165+
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
166+
runtime_mappings: {},
167+
script_fields: {},
168+
stored_fields: ['*'],
171169
max_concurrent_shard_requests: undefined,
172170
},
173171
},

src/platform/packages/private/kbn-generate-csv/src/lib/search_cursor_pit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class SearchCursorPit extends SearchCursor {
8080

8181
const searchParamsPit = {
8282
params: {
83-
body: searchBody,
83+
...searchBody,
8484
max_concurrent_shard_requests: effectiveMaxConcurrentShardRequests,
8585
},
8686
};

src/platform/packages/private/kbn-generate-csv/src/lib/search_cursor_scroll.test.ts

+10-14
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,11 @@ describe('CSV Export Search Cursor', () => {
8080
expect(dataSearchSpy).toBeCalledWith(
8181
{
8282
params: {
83-
body: {
84-
fields: [],
85-
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
86-
runtime_mappings: {},
87-
script_fields: {},
88-
stored_fields: ['*'],
89-
},
83+
fields: [],
84+
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
85+
runtime_mappings: {},
86+
script_fields: {},
87+
stored_fields: ['*'],
9088
ignore_throttled: undefined,
9189
index: 'test-index-pattern-string',
9290
max_concurrent_shard_requests: 5,
@@ -135,13 +133,11 @@ describe('CSV Export Search Cursor', () => {
135133
expect(dataSearchSpy).toBeCalledWith(
136134
{
137135
params: {
138-
body: {
139-
fields: [],
140-
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
141-
runtime_mappings: {},
142-
script_fields: {},
143-
stored_fields: ['*'],
144-
},
136+
fields: [],
137+
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
138+
runtime_mappings: {},
139+
script_fields: {},
140+
stored_fields: ['*'],
145141
ignore_throttled: undefined,
146142
index: 'test-index-pattern-string',
147143
max_concurrent_shard_requests: undefined,

src/platform/packages/private/kbn-generate-csv/src/lib/search_cursor_scroll.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class SearchCursorScroll extends SearchCursor {
3838

3939
const searchParamsScan = {
4040
params: {
41-
body: searchBody,
41+
...searchBody,
4242
index: this.indexPatternTitle,
4343
scroll: scroll.duration(taskInstanceFields),
4444
size: scroll.size,

src/platform/plugins/shared/data/server/search/strategies/ese_search/ese_search_strategy.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe('ES search strategy', () => {
270270
it('sets wait_for_completion_timeout and keep_alive in the request', async () => {
271271
mockSubmitCaller.mockResolvedValueOnce(mockAsyncResponse);
272272

273-
const params = { index: 'foo-*', body: {} };
273+
const params = { index: 'foo-*' };
274274
const esSearch = await enhancedEsSearchStrategyProvider(
275275
mockLegacyConfig$,
276276
mockSearchConfig,
@@ -288,7 +288,7 @@ describe('ES search strategy', () => {
288288
it('calls the rollup API if the index is a rollup type', async () => {
289289
mockApiCaller.mockResolvedValueOnce(mockRollupResponse);
290290

291-
const params = { index: 'foo-程', body: {} };
291+
const params = { index: 'foo-程' };
292292
const esSearch = await enhancedEsSearchStrategyProvider(
293293
mockLegacyConfig$,
294294
mockSearchConfig,

src/platform/plugins/shared/discover/public/application/main/components/no_results/no_results_suggestions/use_fetch_occurances_range.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,19 @@ async function fetchDocumentsTimeRange({
124124
index: dataView.getIndexPattern(),
125125
size: 0,
126126
track_total_hits: false,
127-
body: {
128-
timeout: '20s',
129-
query: dslQuery ?? { match_all: {} },
130-
aggs: {
131-
earliest_timestamp: {
132-
min: {
133-
field: dataView.timeFieldName,
134-
format: 'strict_date_optional_time',
135-
},
127+
timeout: '20s',
128+
query: dslQuery ?? { match_all: {} },
129+
aggs: {
130+
earliest_timestamp: {
131+
min: {
132+
field: dataView.timeFieldName,
133+
format: 'strict_date_optional_time',
136134
},
137-
latest_timestamp: {
138-
max: {
139-
field: dataView.timeFieldName,
140-
format: 'strict_date_optional_time',
141-
},
135+
},
136+
latest_timestamp: {
137+
max: {
138+
field: dataView.timeFieldName,
139+
format: 'strict_date_optional_time',
142140
},
143141
},
144142
},

src/platform/plugins/shared/unified_doc_viewer/public/hooks/use_es_doc_search.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function useEsDocSearch({
7676
data.search.search({
7777
params: {
7878
index: dataView.getIndexPattern(),
79-
body: buildSearchBody(id, index, dataView)?.body,
79+
...buildSearchBody(id, index, dataView),
8080
},
8181
})
8282
);

x-pack/platform/plugins/private/data_visualizer/public/application/common/hooks/use_document_count_stats.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const getDocumentCountStatsRequest = (
111111
};
112112
return {
113113
index,
114-
body: searchBody,
114+
...searchBody,
115115
};
116116
};
117117

0 commit comments

Comments
 (0)