Skip to content

Commit

Permalink
data.search body removals
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Feb 3, 2025
1 parent 0818c90 commit f5c6882
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 59 deletions.
12 changes: 7 additions & 5 deletions examples/search_examples/public/search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ export const SearchExamplesApp = ({
const aggs = [{ type: metricAggType, params: { field: selectedNumericField!.name } }];
const aggsDsl = data.search.aggs.createAggConfigs(dataView, aggs).toDsl();

const body = {
aggs: aggsDsl,
query,
};

const req = {
params: {
index: dataView.title,
body: {
aggs: aggsDsl,
query,
},
...body,
},
// Add a custom request parameter to be consumed by `MyStrategy`.
...(strategy ? { get_cool: getCool } : {}),
Expand All @@ -197,7 +199,7 @@ export const SearchExamplesApp = ({
setAbortController(abortController);

// Submit the search request using the `data.search` service.
setRequest(req.params.body);
setRequest(body);
setRawResponse({});
setWarningContents([]);
setIsLoading(true);
Expand Down
6 changes: 2 additions & 4 deletions examples/unified_doc_viewer/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ function UnifiedDocViewerExamplesApp({ data }: { data: DataPublicPluginStart })
.search({
params: {
index: dataView?.getIndexPattern(),
body: {
fields: ['*'],
_source: false,
},
fields: ['*'],
_source: false,
},
})
.toPromise();
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/lib/indices/kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export async function createDefaultSpace({ index, client }: { index: string; cli
index,
id: 'space:default',
refresh: 'wait_for',
body: {
document: {
type: 'space',
updated_at: new Date().toISOString(),
space: {
Expand Down
4 changes: 1 addition & 3 deletions packages/kbn-es/src/utils/native_realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ exports.NativeRealm = class NativeRealm {
await this._client.security.changePassword({
username,
refresh: 'wait_for',
body: {
password,
},
password,
});
} catch (err) {
const isAnonymousUserPasswordChangeError =
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es/src/utils/native_realm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe('setPassword', () => {
it('sets password for provided user', async () => {
await nativeRealm.setPassword('kibana_system', 'foo');
expect(mockClient.security.changePassword).toHaveBeenCalledWith({
body: { password: 'foo' },
password: 'foo',
refresh: 'wait_for',
username: 'kibana_system',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledTimes(1);
expect(dataSearchSpy).toBeCalledWith(
{
params: {
body: expect.objectContaining({ pit: { id: 'somewhat-pit-id', keep_alive: '10m' } }),
params: expect.objectContaining({
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
max_concurrent_shard_requests: 5,
},
}),
},
expect.objectContaining({
strategy: 'es',
Expand Down Expand Up @@ -160,14 +160,12 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledWith(
{
params: {
body: {
fields: [],
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {},
script_fields: {},
stored_fields: ['*'],
},
fields: [],
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {},
script_fields: {},
stored_fields: ['*'],
max_concurrent_shard_requests: undefined,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class SearchCursorPit extends SearchCursor {

const searchParamsPit = {
params: {
body: searchBody,
...searchBody,
max_concurrent_shard_requests: effectiveMaxConcurrentShardRequests,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledWith(
{
params: {
body: {
fields: [],
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {},
script_fields: {},
stored_fields: ['*'],
},
fields: [],
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {},
script_fields: {},
stored_fields: ['*'],
ignore_throttled: undefined,
index: 'test-index-pattern-string',
max_concurrent_shard_requests: 5,
Expand Down Expand Up @@ -135,13 +133,11 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledWith(
{
params: {
body: {
fields: [],
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {},
script_fields: {},
stored_fields: ['*'],
},
fields: [],
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {},
script_fields: {},
stored_fields: ['*'],
ignore_throttled: undefined,
index: 'test-index-pattern-string',
max_concurrent_shard_requests: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class SearchCursorScroll extends SearchCursor {

const searchParamsScan = {
params: {
body: searchBody,
...searchBody,
index: this.indexPatternTitle,
scroll: scroll.duration(taskInstanceFields),
size: scroll.size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('ES search strategy', () => {
it('sets wait_for_completion_timeout and keep_alive in the request', async () => {
mockSubmitCaller.mockResolvedValueOnce(mockAsyncResponse);

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

const params = { index: 'foo-程', body: {} };
const params = { index: 'foo-程' };
const esSearch = await enhancedEsSearchStrategyProvider(
mockLegacyConfig$,
mockSearchConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,19 @@ async function fetchDocumentsTimeRange({
index: dataView.getIndexPattern(),
size: 0,
track_total_hits: false,
body: {
timeout: '20s',
query: dslQuery ?? { match_all: {} },
aggs: {
earliest_timestamp: {
min: {
field: dataView.timeFieldName,
format: 'strict_date_optional_time',
},
timeout: '20s',
query: dslQuery ?? { match_all: {} },
aggs: {
earliest_timestamp: {
min: {
field: dataView.timeFieldName,
format: 'strict_date_optional_time',
},
latest_timestamp: {
max: {
field: dataView.timeFieldName,
format: 'strict_date_optional_time',
},
},
latest_timestamp: {
max: {
field: dataView.timeFieldName,
format: 'strict_date_optional_time',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function useEsDocSearch({
data.search.search({
params: {
index: dataView.getIndexPattern(),
body: buildSearchBody(id, index, dataView)?.body,
...buildSearchBody(id, index, dataView),
},
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const getDocumentCountStatsRequest = (
};
return {
index,
body: searchBody,
...searchBody,
};
};

Expand Down

0 comments on commit f5c6882

Please sign in to comment.