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 45691d7
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 50 deletions.
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 45691d7

Please sign in to comment.