From 9452a8c5a285ca92be12c56a9fc8e3aef411d7a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 21 Sep 2024 01:23:28 +0000 Subject: [PATCH] Fix ppl commands (#8199) Signed-off-by: sumukhswamy (cherry picked from commit 6ebc1e3b1ca30b3e5981a627b0816b412291a98b) Signed-off-by: github-actions[bot] --- .../public/search/ppl_search_interceptor.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts b/src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts index 973774e1d281..aecb7e32b009 100644 --- a/src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts +++ b/src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts @@ -15,12 +15,12 @@ import { SearchInterceptorDeps, } from '../../../data/public'; import { - formatDate, - SEARCH_STRATEGY, API, EnhancedFetchContext, fetch, + formatDate, QueryAggConfig, + SEARCH_STRATEGY, } from '../../common'; import { QueryEnhancementsPluginStartDependencies } from '../types'; @@ -73,8 +73,10 @@ export class PPLSearchInterceptor extends SearchInterceptor { const query: Query = this.queryService.queryString.getQuery(); const dataset = query.dataset; if (!dataset || !dataset.timeFieldName) return query; + const [baseQuery, ...afterPipeParts] = query.query.split('|'); + const afterPipe = afterPipeParts.length > 0 ? ` | ${afterPipeParts.join('|').trim()}` : ''; const timeFilter = this.getTimeFilter(dataset.timeFieldName); - return { ...query, query: query.query + timeFilter }; + return { ...query, query: baseQuery + timeFilter + afterPipe }; } private getAggConfig(request: IOpenSearchDashboardsSearchRequest, query: Query) {