diff --git a/x-pack/plugins/endpoint/server/routes/endpoints.ts b/x-pack/plugins/endpoint/server/routes/endpoints.ts index a12a5f098351d2..ecd33708e23fb9 100644 --- a/x-pack/plugins/endpoint/server/routes/endpoints.ts +++ b/x-pack/plugins/endpoint/server/routes/endpoints.ts @@ -58,13 +58,13 @@ export function registerEndpointRoutes(router: IRouter, endpointAppContext: Endp } function mapToEndpointResultList( - queryParams: Record, + queryParams: Record, searchResponse: SearchResponse ): EndpointResultList { if (searchResponse.hits.hits.length > 0) { return { - requestPageSize: queryParams.size as number, - requestIndex: queryParams.from as number, + requestPageSize: queryParams.size, + requestIndex: queryParams.from, endpoints: searchResponse.hits.hits .map(response => response.inner_hits.most_recent.hits.hits) .flatMap(data => data as HitSource) @@ -73,8 +73,8 @@ function mapToEndpointResultList( }; } else { return { - requestPageSize: queryParams.size as number, - requestIndex: queryParams.from as number, + requestPageSize: queryParams.size, + requestIndex: queryParams.from, total: 0, endpoints: [], }; diff --git a/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts b/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts index 18b834822b3120..9df4916f3f555e 100644 --- a/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts +++ b/x-pack/plugins/endpoint/server/services/endpoint/endpoint_query_builders.ts @@ -14,8 +14,10 @@ export class AllEndpointsQueryBuilder { this.request = request; this.endpointAppContext = endpointAppContext; } - - async toQueryParams(): Promise> { + /* aggregating by endpoint machine id and retrieving the latest of each group of events + related to an endpoint by machine id using elastic search collapse functionality + */ + async toQueryParams(): Promise> { const paging = await this.paging(); return { body: {