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
15 changes: 13 additions & 2 deletions x-pack/legacy/plugins/apm/typings/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ declare module 'elasticsearch' {
| 'extended_stats'
| 'filter'
| 'filters'
| 'cardinality';
| 'cardinality'
| 'sampler'
| 'value_count';

type AggOptions = AggregationOptionMap & {
[key: string]: any;
Expand Down Expand Up @@ -71,6 +73,12 @@ declare module 'elasticsearch' {
>;
};

type SamplerAggregation<SubAggregationMap> = SubAggregation<
SubAggregationMap
> & {
doc_count: number;
};

interface AggregatedValue {
value: number | null;
}
Expand All @@ -82,7 +90,9 @@ declare module 'elasticsearch' {
max: AggregatedValue;
min: AggregatedValue;
sum: AggregatedValue;
terms: BucketAggregation<AggregationOption[AggregationName]>;
value_count: AggregatedValue;
// Elasticsearch might return terms with numbers, but this is a more limited type
terms: BucketAggregation<AggregationOption[AggregationName], string>;
date_histogram: BucketAggregation<
AggregationOption[AggregationName],
number
Expand Down Expand Up @@ -128,6 +138,7 @@ declare module 'elasticsearch' {
cardinality: {
value: number;
};
sampler: SamplerAggregation<AggregationOption[AggregationName]>;
}[AggregationType & keyof AggregationOption[AggregationName]];
}
>;
Expand Down
36 changes: 36 additions & 0 deletions x-pack/legacy/plugins/lens/common/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export interface BucketedAggregation<KeyType = string> {
buckets: Array<{
key: KeyType;
count: number;
}>;
}

export interface NumberStatsResult {
count: number;
histogram: BucketedAggregation<number>;
topValues: BucketedAggregation<number>;
}

export interface TopValuesResult {
count: number;
topValues: BucketedAggregation<string>;
}

export interface FieldStatsResponse<KeyType = unknown> {
// Total count of documents
totalDocuments?: number;
// If sampled, the exact number of matching documents
sampledDocuments?: number;
// If sampled, the exact number of values sampled. Can be higher than documents
// because Elasticsearch supports arrays for all fields
sampledValues?: number;
// Histogram and values are based on distinct values, not based on documents
histogram?: BucketedAggregation<KeyType>;
topValues?: BucketedAggregation<KeyType>;
}
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/lens/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/

export * from './api';
export * from './constants';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.lnsFieldItem__topValue {
margin-bottom: $euiSizeS;

&:last-of-type {
margin-bottom: 0;
}
}

.lnsFieldItem__topValueProgress {
background-color: $euiColorLightestShade;

&::-webkit-progress-bar {
background-color: $euiColorLightestShade;
}
}

.lnsFieldItem__fieldPopoverPanel {
min-width: 260px;
max-width: 300px;
}

Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,14 @@ export const InnerIndexPatternDataPanel = function InnerIndexPatternDataPanel({
const overallField = fieldByName[field.name];
return (
<FieldItem
core={core}
indexPattern={currentIndexPattern}
key={field.name}
field={field}
highlight={localState.nameFilter.toLowerCase()}
exists={overallField ? !!overallField.exists : false}
dateRange={dateRange}
query={query}
/>
);
})}
Expand Down
Loading