import { ISearchRequestParams } from '../../../../../../../../src/plugins/data/common' ; import { AgentsRequestOptions } from '../../../../../common/search_strategy' ; import { createQueryFilterClauses } from '../../../../../common/utils/build_query' ; export const buildAgentsQuery = ( { filterQuery , pagination : { cursorStart , querySize } , sort , aggregations , } ) : ISearchRequestParams => { const filter = [ { term : { active : { value : 'true' } } } , ... createQueryFilterClauses ( filterQuery ) , ] ; const dslQuery = { allow_no_indices : true , index : '.fleet-agents' , ignore_unavailable : true , body : { query : { bool : { filter , } , } , aggs : aggregations , track_total_hits : true , sort : [ { [ sort . field ] : { order : sort . direction , } , } , ] , size : querySize , from : cursorStart , } , } ; return dslQuery ; } ;