import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ; export function buildBaseFilterCriteria ( timeFieldName ? , earliestMs ? , latestMs ? , query ? ) { const filterCriteria = [ ] ; if ( timeFieldName && earliestMs && latestMs ) { filterCriteria . push ( { range : { [ timeFieldName ] : { gte : earliestMs , lte : latestMs , format : 'epoch_millis' , } , } , } ) ; } if ( query ) { filterCriteria . push ( query ) ; } return filterCriteria ; } export function buildSamplerAggregation ( aggs , samplerShardSize ) { if ( samplerShardSize < 1 ) { return aggs ; } return { sample : { sampler : { shard_size : samplerShardSize , } , aggs , } , } ; } export function getSamplerAggregationsResponsePath ( samplerShardSize ) { return samplerShardSize > 0 ? [ 'sample' ] : [ ] ; }