Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Aug 12, 2022
1 parent 5ca1470 commit b5ee47e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions x-pack/plugins/lens/server/routes/existing_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ async function fetchFieldExistence({

const uiSettingsClient = (await context.core).uiSettings.client;
const metaFields: string[] = await uiSettingsClient.get(UI_SETTINGS.META_FIELDS);
const dataView = spec
? await dataViewsService.create(spec)
: await dataViewsService.get(indexPatternId);
const dataView =
spec && Object.keys(spec).length !== 0
? await dataViewsService.create(spec)
: await dataViewsService.get(indexPatternId);
const allFields = buildFieldList(dataView, metaFields);
const existingFieldList = await dataViewsService.getFieldsForIndexPattern(dataView, {
// filled in by data views service
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugins/lens/server/routes/field_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ export async function initFieldsRoute(setup: CoreSetup<PluginStartContract>) {
);

try {
const indexPattern = spec
? await indexPatternsService.create(spec)
: await indexPatternsService.get(req.params.indexPatternId);
const indexPattern =
spec && Object.keys(spec).length !== 0
? await indexPatternsService.create(spec)
: await indexPatternsService.get(req.params.indexPatternId);

const timeFieldName = indexPattern.timeFieldName;
const field = indexPattern.fields.find((f) => f.name === fieldName);
Expand Down

0 comments on commit b5ee47e

Please sign in to comment.