44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import { mergeProjection } from '../../../../common/projections/util/merge_projection ' ;
7+ import { ESFilter } from '../../../../typings/elasticsearch ' ;
88import {
99 PROCESSOR_EVENT ,
1010 AGENT_NAME ,
1111 SERVICE_ENVIRONMENT ,
1212 TRANSACTION_DURATION ,
1313} from '../../../../common/elasticsearch_fieldnames' ;
1414import { PromiseReturnType } from '../../../../typings/common' ;
15- import {
16- Setup ,
17- SetupTimeRange ,
18- SetupUIFilters ,
19- } from '../../helpers/setup_request' ;
2015import { getServicesProjection } from '../../../../common/projections/services' ;
16+ import { ApmIndicesConfig } from '../../settings/apm_indices/get_apm_indices' ;
17+ import { ESClient } from '../../helpers/es_client' ;
2118
2219export type ServiceListAPIResponse = PromiseReturnType < typeof getServicesItems > ;
23- export async function getServicesItems (
24- setup : Setup & SetupTimeRange & SetupUIFilters
25- ) {
26- const { start, end, client } = setup ;
27-
28- const projection = getServicesProjection ( { setup } ) ;
20+ export async function getServicesItems ( {
21+ start,
22+ end,
23+ uiFiltersES,
24+ indices,
25+ client,
26+ } : {
27+ start : number ;
28+ end : number ;
29+ uiFiltersES : ESFilter [ ] ;
30+ indices : ApmIndicesConfig ;
31+ client : ESClient ;
32+ } ) {
33+ const projection = getServicesProjection ( {
34+ start,
35+ end,
36+ uiFiltersES,
37+ indices,
38+ } ) ;
2939
30- const params = mergeProjection ( projection , {
40+ const params = {
3141 body : {
42+ index : projection . index ,
3243 size : 0 ,
44+ query : projection . body . query ,
3345 aggs : {
3446 services : {
3547 terms : {
36- ... projection . body . aggs . services . terms ,
48+ field : projection . body . aggs . services . terms . field ,
3749 size : 500 ,
3850 } ,
3951 aggs : {
@@ -53,7 +65,7 @@ export async function getServicesItems(
5365 } ,
5466 } ,
5567 } ,
56- } ) ;
68+ } ;
5769
5870 const resp = await client . search ( params ) ;
5971 const aggs = resp . aggregations ;
0 commit comments