Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/plugins/data_views/common/data_views/data_views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ describe('IndexPatterns', () => {
expect(apiClient.getFieldsForWildcard).toBeCalledTimes(2);
});

test('getFieldsForWildcard called with allowNoIndex set to true as default ', async () => {
const id = '1';
await indexPatterns.get(id);
expect(apiClient.getFieldsForWildcard).toBeCalledWith({
allowNoIndex: true,
indexFilter: undefined,
metaFields: false,
pattern: 'something',
rollupIndex: undefined,
type: undefined,
});
});

test('does cache ad-hoc data views', async () => {
const id = '1';

Expand Down Expand Up @@ -608,9 +621,8 @@ describe('IndexPatterns', () => {
expect(indexPattern.fields.length).toBe(1);
});

test('refreshFields properly includes allowNoIndex', async () => {
test('refreshFields defaults allowNoIndex to true', async () => {
const indexPatternSpec: DataViewSpec = {
allowNoIndex: true,
title: 'test',
};

Expand Down
10 changes: 5 additions & 5 deletions src/plugins/data_views/common/data_views/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,12 @@ export class DataViewsService {
*/
getFieldsForIndexPattern = async (
indexPattern: DataView | DataViewSpec,
options?: GetFieldsOptions
options?: Omit<GetFieldsOptions, 'allowNoIndex'>
) =>
this.getFieldsForWildcard({
type: indexPattern.type,
rollupIndex: indexPattern?.typeMeta?.params?.rollup_index,
allowNoIndex: indexPattern.allowNoIndex,
allowNoIndex: true,
...options,
pattern: indexPattern.title as string,
});
Expand All @@ -530,20 +530,20 @@ export class DataViewsService {
return this.apiClient.getFieldsForWildcard({
type: dataView.type,
rollupIndex: dataView?.typeMeta?.params?.rollup_index,
allowNoIndex: dataView.allowNoIndex,
allowNoIndex: true,
pattern: dataView.getIndexPattern(),
metaFields,
});
};

private getFieldsAndIndicesForWildcard = async (options: GetFieldsOptions) => {
const metaFields = await this.config.get<string[]>(META_FIELDS);
return await this.apiClient.getFieldsForWildcard({
return this.apiClient.getFieldsForWildcard({
pattern: options.pattern,
metaFields,
type: options.type,
rollupIndex: options.rollupIndex,
allowNoIndex: options.allowNoIndex,
allowNoIndex: true,
indexFilter: options.indexFilter,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ export async function getFieldCapabilities(params: FieldCapabilitiesParams) {
indexFilter,
fields,
});
const fieldsFromFieldCapsByName = keyBy(readFieldCapsResponse(esFieldCaps.body), 'name');
const fieldCapsArr = readFieldCapsResponse(esFieldCaps.body);
const fieldsFromFieldCapsByName = keyBy(fieldCapsArr, 'name');

const allFieldsUnsorted = Object.keys(fieldsFromFieldCapsByName)
// not all meta fields are provided, so remove and manually add
.filter((name) => !fieldsFromFieldCapsByName[name].metadata_field)
.concat(metaFields)
.concat(fieldCapsArr.length ? metaFields : [])
.reduce<{ names: string[]; map: Map<string, string> }>(
(agg, value) => {
// This is intentionally using a Map to be highly optimized with very large indexes AND be safe for user provided data
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/discover/group3/_sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.discover.waitUntilSidebarHasLoaded();

expect(await PageObjects.discover.getSidebarAriaDescription()).to.be(
'0 available fields. 0 meta fields.'
'0 available fields. 0 empty fields. 0 meta fields.'
);
await testSubjects.existOrFail(
await testSubjects.missingOrFail(
`${PageObjects.discover.getSidebarSectionSelector('available')}-fetchWarning`
);
await testSubjects.existOrFail(
Expand Down