import { ESFilter } from '../../../../../../../src/core/types/elasticsearch' ; import { rangeQuery , kqlQuery } from '../../../../../observability/server' ; import { environmentQuery } from '../../../../common/utils/environment_query' ; import { SERVICE_NAME , TRANSACTION_NAME , TRANSACTION_TYPE , PROCESSOR_EVENT , } from '../../../../common/elasticsearch_fieldnames' ; import { ProcessorEvent } from '../../../../common/processor_event' ; import { CorrelationsClientParams } from '../../../../common/correlations/types' ; export function getCorrelationsFilters ( { environment , kuery , serviceName , transactionType , transactionName , start , end , } ) { const correlationsFilters = [ { term : { [ PROCESSOR_EVENT ] : ProcessorEvent . transaction } } , ... rangeQuery ( start , end ) , ... environmentQuery ( environment ) , ... kqlQuery ( kuery ) , ] ; if ( serviceName ) { correlationsFilters . push ( { term : { [ SERVICE_NAME ] : serviceName } } ) ; } if ( transactionType ) { correlationsFilters . push ( { term : { [ TRANSACTION_TYPE ] : transactionType } } ) ; } if ( transactionName ) { correlationsFilters . push ( { term : { [ TRANSACTION_NAME ] : transactionName } } ) ; } return correlationsFilters ; }