[Lens] Show fields when using indexpattern without time field (#54804)

This commit is contained in:
Wylie Conlon 2020-01-14 16:31:44 -05:00 committed by GitHub
parent 60f647572e
commit 4869e02b62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
@ -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: {