mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[data views] Stored fields are always requested, we don't need logic around it (#171815)
## Summary Stored field handling is basically a dead code path. `['*']` is always sent so lets push this closer to the query. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
f98f282388
commit
2403bc8c88
11 changed files with 22 additions and 25 deletions
|
@ -108,7 +108,7 @@ export const buildDataViewMock = ({
|
|||
fields: dataViewFields,
|
||||
type: 'default',
|
||||
getName: () => name,
|
||||
getComputedFields: () => ({ docvalueFields: [], scriptFields: {}, storedFields: ['*'] }),
|
||||
getComputedFields: () => ({ docvalueFields: [], scriptFields: {} }),
|
||||
getSourceFiltering: () => ({}),
|
||||
getIndexPattern: () => `${name}-title`,
|
||||
getFieldByName: jest.fn((fieldName: string) => dataViewFields.getByName(fieldName)),
|
||||
|
|
|
@ -281,7 +281,6 @@ describe('SearchSource', () => {
|
|||
searchSource.setField('index', {
|
||||
...indexPattern,
|
||||
getComputedFields: () => ({
|
||||
storedFields: ['hello'],
|
||||
scriptFields: { world: {} },
|
||||
docvalueFields: ['@timestamp'],
|
||||
runtimeFields,
|
||||
|
@ -289,7 +288,7 @@ describe('SearchSource', () => {
|
|||
} as unknown as DataView);
|
||||
|
||||
const request = searchSource.getSearchRequestBody();
|
||||
expect(request.stored_fields).toEqual(['hello']);
|
||||
expect(request.stored_fields).toEqual(['*']);
|
||||
expect(request.script_fields).toEqual({ world: {} });
|
||||
expect(request.fields).toEqual(['@timestamp']);
|
||||
expect(request.runtime_mappings).toEqual(runtimeFields);
|
||||
|
|
|
@ -779,12 +779,11 @@ export class SearchSource {
|
|||
const metaFields = getConfig(UI_SETTINGS.META_FIELDS) ?? [];
|
||||
|
||||
// get some special field types from the index pattern
|
||||
const { docvalueFields, scriptFields, storedFields, runtimeFields } = index
|
||||
const { docvalueFields, scriptFields, runtimeFields } = index
|
||||
? index.getComputedFields()
|
||||
: {
|
||||
docvalueFields: [],
|
||||
scriptFields: {},
|
||||
storedFields: ['*'],
|
||||
runtimeFields: {},
|
||||
};
|
||||
const fieldListProvided = !!body.fields;
|
||||
|
@ -798,7 +797,7 @@ export class SearchSource {
|
|||
...scriptFields,
|
||||
}
|
||||
: {};
|
||||
body.stored_fields = storedFields;
|
||||
body.stored_fields = ['*'];
|
||||
body.runtime_mappings = runtimeFields || {};
|
||||
|
||||
// apply source filters from index pattern if specified by the user
|
||||
|
|
|
@ -136,10 +136,6 @@ describe('IndexPattern', () => {
|
|||
expect(indexPattern.getComputedFields).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
test('should request all stored fields', () => {
|
||||
expect(indexPattern.getComputedFields().storedFields).toContain('*');
|
||||
});
|
||||
|
||||
test('should request date fields as docvalue_fields', () => {
|
||||
const { docvalueFields } = indexPattern.getComputedFields();
|
||||
const docValueFieldNames = docvalueFields.map((field) => field.field);
|
||||
|
|
|
@ -85,7 +85,6 @@ export class DataView extends AbstractDataView implements DataViewBase {
|
|||
const scriptFields: Record<string, estypes.ScriptField> = {};
|
||||
if (!this.fields) {
|
||||
return {
|
||||
storedFields: ['*'],
|
||||
scriptFields,
|
||||
docvalueFields: [] as Array<{ field: string; format: string }>,
|
||||
runtimeFields: {},
|
||||
|
@ -117,7 +116,6 @@ export class DataView extends AbstractDataView implements DataViewBase {
|
|||
const runtimeFields = this.getRuntimeMappings();
|
||||
|
||||
return {
|
||||
storedFields: ['*'],
|
||||
scriptFields,
|
||||
docvalueFields,
|
||||
runtimeFields,
|
||||
|
|
|
@ -40,7 +40,7 @@ const services = {
|
|||
describe('Test of <Doc /> helper / hook', () => {
|
||||
test('buildSearchBody given useNewFieldsApi is false', () => {
|
||||
const dataView = {
|
||||
getComputedFields: () => ({ storedFields: [], scriptFields: [], docvalueFields: [] }),
|
||||
getComputedFields: () => ({ scriptFields: [], docvalueFields: [] }),
|
||||
} as unknown as DataView;
|
||||
const actual = buildSearchBody('1', index, dataView, false);
|
||||
expect(actual).toMatchInlineSnapshot(`
|
||||
|
@ -67,7 +67,9 @@ describe('Test of <Doc /> helper / hook', () => {
|
|||
},
|
||||
},
|
||||
"script_fields": Array [],
|
||||
"stored_fields": Array [],
|
||||
"stored_fields": Array [
|
||||
"*",
|
||||
],
|
||||
"version": true,
|
||||
},
|
||||
}
|
||||
|
@ -76,7 +78,7 @@ describe('Test of <Doc /> helper / hook', () => {
|
|||
|
||||
test('buildSearchBody useNewFieldsApi is true', () => {
|
||||
const dataView = {
|
||||
getComputedFields: () => ({ storedFields: [], scriptFields: [], docvalueFields: [] }),
|
||||
getComputedFields: () => ({ scriptFields: [], docvalueFields: [] }),
|
||||
} as unknown as DataView;
|
||||
const actual = buildSearchBody('1', index, dataView, true);
|
||||
expect(actual).toMatchInlineSnapshot(`
|
||||
|
@ -108,7 +110,9 @@ describe('Test of <Doc /> helper / hook', () => {
|
|||
},
|
||||
"runtime_mappings": Object {},
|
||||
"script_fields": Array [],
|
||||
"stored_fields": Array [],
|
||||
"stored_fields": Array [
|
||||
"*",
|
||||
],
|
||||
"version": true,
|
||||
},
|
||||
}
|
||||
|
@ -117,7 +121,7 @@ describe('Test of <Doc /> helper / hook', () => {
|
|||
|
||||
test('buildSearchBody with requestSource', () => {
|
||||
const dataView = {
|
||||
getComputedFields: () => ({ storedFields: [], scriptFields: [], docvalueFields: [] }),
|
||||
getComputedFields: () => ({ scriptFields: [], docvalueFields: [] }),
|
||||
} as unknown as DataView;
|
||||
const actual = buildSearchBody('1', index, dataView, true, true);
|
||||
expect(actual).toMatchInlineSnapshot(`
|
||||
|
@ -150,7 +154,9 @@ describe('Test of <Doc /> helper / hook', () => {
|
|||
},
|
||||
"runtime_mappings": Object {},
|
||||
"script_fields": Array [],
|
||||
"stored_fields": Array [],
|
||||
"stored_fields": Array [
|
||||
"*",
|
||||
],
|
||||
"version": true,
|
||||
},
|
||||
}
|
||||
|
@ -160,7 +166,6 @@ describe('Test of <Doc /> helper / hook', () => {
|
|||
test('buildSearchBody with runtime fields', () => {
|
||||
const dataView = {
|
||||
getComputedFields: () => ({
|
||||
storedFields: [],
|
||||
scriptFields: [],
|
||||
docvalueFields: [],
|
||||
runtimeFields: {
|
||||
|
@ -210,7 +215,9 @@ describe('Test of <Doc /> helper / hook', () => {
|
|||
},
|
||||
},
|
||||
"script_fields": Array [],
|
||||
"stored_fields": Array [],
|
||||
"stored_fields": Array [
|
||||
"*",
|
||||
],
|
||||
"version": true,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ export function buildSearchBody(
|
|||
filter: [{ ids: { values: [id] } }, { term: { _index: index } }],
|
||||
},
|
||||
},
|
||||
stored_fields: computedFields.storedFields,
|
||||
stored_fields: ['*'],
|
||||
script_fields: computedFields.scriptFields,
|
||||
version: true,
|
||||
},
|
||||
|
|
|
@ -91,7 +91,7 @@ export const buildDataViewMock = ({
|
|||
metaFields: ['_index', '_score'],
|
||||
fields: dataViewFields,
|
||||
getName: () => name,
|
||||
getComputedFields: () => ({ docvalueFields: [], scriptFields: {}, storedFields: ['*'] }),
|
||||
getComputedFields: () => ({ docvalueFields: [], scriptFields: {} }),
|
||||
getSourceFiltering: () => ({}),
|
||||
getFieldByName: jest.fn((fieldName: string) => dataViewFields.getByName(fieldName)),
|
||||
timeFieldName: timeFieldName || '',
|
||||
|
|
|
@ -100,7 +100,7 @@ export const buildDataViewMock = ({
|
|||
fields: dataViewFields,
|
||||
type: 'default',
|
||||
getName: () => name,
|
||||
getComputedFields: () => ({ docvalueFields: [], scriptFields: {}, storedFields: ['*'] }),
|
||||
getComputedFields: () => ({ docvalueFields: [], scriptFields: {} }),
|
||||
getSourceFiltering: () => ({}),
|
||||
getIndexPattern: () => `${name}-title`,
|
||||
getFieldByName: jest.fn((fieldName: string) => dataViewFields.getByName(fieldName)),
|
||||
|
|
|
@ -49,7 +49,6 @@ export const createIndexPatternMock = ({
|
|||
getComputedFields: () => ({
|
||||
runtimeFields: runtimeFields ?? {},
|
||||
scriptFields: {},
|
||||
storedFields: [],
|
||||
docvalueFields: [],
|
||||
}),
|
||||
getRuntimeMappings: () => runtimeFields ?? {},
|
||||
|
|
|
@ -99,7 +99,6 @@ export const createIndexPatternMock = ({
|
|||
return accumulatedRuntimeFields;
|
||||
}, {}),
|
||||
scriptFields: {},
|
||||
storedFields: [],
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue