mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [Discover] Do not set fieldsFromSource when not using fields API (#98575) * [Discover] Do not set fieldsFromSource when not using fields API * Add Search Source unit test * Add Search Source unit test * Fix await error Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
8453993f6c
commit
f8beb1e43b
3 changed files with 37 additions and 2 deletions
|
@ -486,6 +486,13 @@ describe('SearchSource', () => {
|
|||
const request = await searchSource.getSearchRequestBody();
|
||||
expect(request.stored_fields).toEqual(['*']);
|
||||
});
|
||||
|
||||
test('_source is not set when using the fields API', async () => {
|
||||
searchSource.setField('fields', ['*']);
|
||||
const request = await searchSource.getSearchRequestBody();
|
||||
expect(request.fields).toEqual(['*']);
|
||||
expect(request._source).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('source filters handling', () => {
|
||||
|
|
|
@ -136,4 +136,34 @@ describe('updateSearchSource', () => {
|
|||
]);
|
||||
expect(volatileSearchSourceMock.getField('fieldsFromSource')).toBe(undefined);
|
||||
});
|
||||
|
||||
test('does not explicitly request fieldsFromSource when not using fields API', async () => {
|
||||
const persistentSearchSourceMock = createSearchSourceMock({});
|
||||
const volatileSearchSourceMock = createSearchSourceMock({});
|
||||
const sampleSize = 250;
|
||||
updateSearchSource({
|
||||
persistentSearchSource: persistentSearchSourceMock,
|
||||
volatileSearchSource: volatileSearchSourceMock,
|
||||
indexPattern: indexPatternMock,
|
||||
services: ({
|
||||
data: dataPluginMock.createStartContract(),
|
||||
uiSettings: ({
|
||||
get: (key: string) => {
|
||||
if (key === SAMPLE_SIZE_SETTING) {
|
||||
return sampleSize;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
} as unknown) as IUiSettingsClient,
|
||||
} as unknown) as DiscoverServices,
|
||||
sort: [] as SortOrder[],
|
||||
columns: [],
|
||||
useNewFieldsApi: false,
|
||||
showUnmappedFields: false,
|
||||
});
|
||||
expect(persistentSearchSourceMock.getField('index')).toEqual(indexPatternMock);
|
||||
expect(volatileSearchSourceMock.getField('size')).toEqual(sampleSize);
|
||||
expect(volatileSearchSourceMock.getField('fields')).toEqual(undefined);
|
||||
expect(volatileSearchSourceMock.getField('fieldsFromSource')).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -65,8 +65,6 @@ export function updateSearchSource({
|
|||
volatileSearchSource.setField('fields', [fields]);
|
||||
} else {
|
||||
volatileSearchSource.removeField('fields');
|
||||
const fieldNames = indexPattern.fields.map((field) => field.name);
|
||||
volatileSearchSource.setField('fieldsFromSource', fieldNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue