import { i18n } from '@osd/i18n' ; import { MetricAggType , IMetricAggConfig } from './metric_agg_type' ; import { METRIC_TYPES } from './metric_agg_types' ; import { OSD_FIELD_TYPES } from '../../../../common' ; import { BaseAggParams } from '../types' ; const uniqueCountTitle = i18n . translate ( 'data.search.aggs.metrics.uniqueCountTitle' , { defaultMessage : 'Unique Count' , } ) ; export interface AggParamsCardinality extends BaseAggParams { field : string ; } export const getCardinalityMetricAgg = ( ) => new MetricAggType ( { name : METRIC_TYPES . CARDINALITY , title : uniqueCountTitle , makeLabel ( aggConfig ) { return i18n . translate ( 'data.search.aggs.metrics.uniqueCountLabel' , { defaultMessage : 'Unique count of {field}' , values : { field : aggConfig . getFieldDisplayName ( ) } , } ) ; } , getSerializedFormat ( agg ) { return { id : 'number' , } ; } , params : [ { name : 'field' , type : 'field' , filterFieldTypes : Object . values ( OSD_FIELD_TYPES ) . filter ( ( type ) => type !== OSD_FIELD_TYPES . HISTOGRAM ) , } , ] , } ) ;