import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ; import type { FieldValuePair , CorrelationsParams , } from '../../../../common/correlations/types' ; import { getCorrelationsFilters } from './get_filters' ; export const getTermsQuery = ( { fieldName , fieldValue } ) => { return { term : { [ fieldName ] : fieldValue } } ; } ; interface QueryParams { params : CorrelationsParams ; termFilters ? : FieldValuePair [ ] ; } export const getQueryWithParams = ( { params , termFilters } ) => { const { environment , kuery , serviceName , start , end , transactionType , transactionName , } = params ; const correlationFilters = getCorrelationsFilters ( { environment , kuery , serviceName , transactionType , transactionName , start , end , } ) ; return { bool : { filter : [ ... correlationFilters , ... ( Array . isArray ( termFilters ) ? termFilters . map ( getTermsQuery ) : [ ] ) , ] as estypes . QueryDslQueryContainer [ ] , } , } ; } ;