Skip to content

Commit

Permalink
[Lens] Show fields when using indexpattern without time field (#54804) (
Browse files Browse the repository at this point in the history
  • Loading branch information
Wylie Conlon committed Jan 14, 2020
1 parent 96a6a4f commit 25bf3f2
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions x-pack/legacy/plugins/lens/server/routes/existing_fields.ts
Expand Up @@ -204,8 +204,27 @@ async function fetchIndexPatternStats({
toDate?: string;
fields: Field[];
}) {
if (!timeFieldName || !fromDate || !toDate) {
return [];
let query;

if (timeFieldName && fromDate && toDate) {
query = {
bool: {
filter: [
{
range: {
[timeFieldName]: {
gte: fromDate,
lte: toDate,
},
},
},
],
},
};
} else {
query = {
match_all: {},
};
}
const viableFields = fields.filter(
f => !f.isScript && !f.isAlias && !metaFields.includes(f.name)
Expand All @@ -217,20 +236,7 @@ async function fetchIndexPatternStats({
body: {
size: SAMPLE_SIZE,
_source: viableFields.map(f => f.name),
query: {
bool: {
filter: [
{
range: {
[timeFieldName]: {
gte: fromDate,
lte: toDate,
},
},
},
],
},
},
query,
script_fields: scriptedFields.reduce((acc, field) => {
acc[field.name] = {
script: {
Expand Down

0 comments on commit 25bf3f2

Please sign in to comment.