Skip to content

Commit

Permalink
Fix ppl commands (opensearch-project#8199)
Browse files Browse the repository at this point in the history
Signed-off-by: sumukhswamy <[email protected]>
  • Loading branch information
sumukhswamy authored Sep 19, 2024
1 parent 6f9672b commit 6ebc1e3
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6ebc1e3

Please sign in to comment.