diff --git a/public/components/application_analytics/components/flyout_components/service_detail_flyout.tsx b/public/components/application_analytics/components/flyout_components/service_detail_flyout.tsx index 94fb24262..418fb222b 100644 --- a/public/components/application_analytics/components/flyout_components/service_detail_flyout.tsx +++ b/public/components/application_analytics/components/flyout_components/service_detail_flyout.tsx @@ -133,7 +133,7 @@ export function ServiceDetailFlyout(props: ServiceFlyoutProps) { handleServiceViewRequest(serviceName, http, serviceDSL, setFields, mode); handleServiceMapRequest(http, serviceDSL, mode, '', setServiceMap, serviceName); const spanDSL = filtersToDsl(mode, filters, query, startTime, endTime, 'app', appConfigs); - spanDSL.query.bool.must.push({ + spanDSL.query.bool.filter.push({ term: { serviceName, }, diff --git a/public/components/trace_analytics/components/common/helper_functions.tsx b/public/components/trace_analytics/components/common/helper_functions.tsx index aa110ea50..cb889ebd8 100644 --- a/public/components/trace_analytics/components/common/helper_functions.tsx +++ b/public/components/trace_analytics/components/common/helper_functions.tsx @@ -403,10 +403,10 @@ export const filtersToDsl = ( }, }, }; - DSL.query.bool.must.push(timeFilter); + DSL.query.bool.filter.push(timeFilter); DSL.custom.timeFilter.push(timeFilter); if (query.length > 0) { - DSL.query.bool.must.push({ + DSL.query.bool.filter.push({ query_string: { query, }, diff --git a/public/components/trace_analytics/components/services/service_view.tsx b/public/components/trace_analytics/components/services/service_view.tsx index 356f17ea1..bc93b6793 100644 --- a/public/components/trace_analytics/components/services/service_view.tsx +++ b/public/components/trace_analytics/components/services/service_view.tsx @@ -405,13 +405,13 @@ export function ServiceView(props: ServiceViewProps) { processTimeStamp(props.endTime, mode) ); if (mode === 'data_prepper') { - spanDSL.query.bool.must.push({ + spanDSL.query.bool.filter.push({ term: { serviceName: props.serviceName, }, }); } else if (mode === 'jaeger') { - spanDSL.query.bool.must.push({ + spanDSL.query.bool.filter.push({ term: { 'process.serviceName': props.serviceName, }, @@ -419,7 +419,7 @@ export function ServiceView(props: ServiceViewProps) { } spanFilters.map(({ field, value }) => { if (value != null) { - spanDSL.query.bool.must.push({ + spanDSL.query.bool.filter.push({ term: { [field]: value, }, diff --git a/public/components/trace_analytics/components/traces/span_detail_panel.tsx b/public/components/trace_analytics/components/traces/span_detail_panel.tsx index dedbd58aa..e59fb7e2f 100644 --- a/public/components/trace_analytics/components/traces/span_detail_panel.tsx +++ b/public/components/trace_analytics/components/traces/span_detail_panel.tsx @@ -132,7 +132,7 @@ export function SpanDetailPanel(props: { }; spanFilters.map(({ field, value }) => { if (value != null) { - spanDSL.query.bool.must.push({ + spanDSL.query.bool.filter.push({ term: { [field]: value, }, diff --git a/public/components/trace_analytics/requests/queries/services_queries.ts b/public/components/trace_analytics/requests/queries/services_queries.ts index ab3cd3ce0..b9bc9e124 100644 --- a/public/components/trace_analytics/requests/queries/services_queries.ts +++ b/public/components/trace_analytics/requests/queries/services_queries.ts @@ -46,14 +46,14 @@ export const getServicesQuery = ( }; if (mode === 'jaeger') { if (serviceName) { - query.query.bool.must.push({ + query.query.bool.filter.push({ term: { 'process.serviceName': serviceName, }, }); } DSL?.custom?.serviceNames?.map((service: string) => { - query.query.bool.must.push({ + query.query.bool.filter.push({ term: { 'process.serviceName': service, }, @@ -68,14 +68,14 @@ export const getServicesQuery = ( }); } else { if (serviceName) { - query.query.bool.must.push({ + query.query.bool.filter.push({ term: { serviceName, }, }); } DSL?.custom?.serviceNames?.map((service: string) => { - query.query.bool.must.push({ + query.query.bool.filter.push({ term: { serviceName: service, }, @@ -457,8 +457,8 @@ export const getServiceMetricsQuery = ( }, }; if (DSL.custom?.timeFilter.length > 0) { - jaegerQuery.query.bool.must.push(...DSL.custom.timeFilter); - dataPrepperQuery.query.bool.must.push(...DSL.custom.timeFilter); + jaegerQuery.query.bool.filter.push(...DSL.custom.timeFilter); + dataPrepperQuery.query.bool.filter.push(...DSL.custom.timeFilter); } return mode === 'jaeger' ? jaegerQuery : dataPrepperQuery; }; diff --git a/public/components/trace_analytics/requests/queries/traces_queries.ts b/public/components/trace_analytics/requests/queries/traces_queries.ts index f60820ddc..c9297999a 100644 --- a/public/components/trace_analytics/requests/queries/traces_queries.ts +++ b/public/components/trace_analytics/requests/queries/traces_queries.ts @@ -72,6 +72,7 @@ export const getTracesQuery = ( order: { [field]: direction, }, + execution_hint: 'map', }, aggs: { latency: { @@ -118,6 +119,7 @@ export const getTracesQuery = ( }, }, }, + track_total_hits: false, }; const dataPrepperQuery: any = { size: 0, @@ -137,6 +139,7 @@ export const getTracesQuery = ( order: { [field]: direction, }, + execution_hint: 'map', }, aggs: { latency: { @@ -173,14 +176,15 @@ export const getTracesQuery = ( }, }, }, + track_total_hits: false, }; if (traceId) { - jaegerQuery.query.bool.must.push({ + jaegerQuery.query.bool.filter.push({ term: { traceID: traceId, }, }); - dataPrepperQuery.query.bool.must.push({ + dataPrepperQuery.query.bool.filter.push({ term: { traceId, }, diff --git a/server/routes/trace_analytics_dsl_router.ts b/server/routes/trace_analytics_dsl_router.ts index 4fe62ab5d..4d99ea401 100644 --- a/server/routes/trace_analytics_dsl_router.ts +++ b/server/routes/trace_analytics_dsl_router.ts @@ -126,6 +126,7 @@ export function registerTraceAnalyticsDslRouter(router: IRouter, dataSourceEnabl }) ), script_fields: schema.maybe(schema.any()), + track_total_hits: schema.maybe(schema.boolean()), }), query: schema.object({ dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),