diff --git a/src/plugins/data/public/query/query_string/language_service/lib/dql_language.ts b/src/plugins/data/public/query/query_string/language_service/lib/dql_language.ts index fef093f18554..865c6aae84f5 100644 --- a/src/plugins/data/public/query/query_string/language_service/lib/dql_language.ts +++ b/src/plugins/data/public/query/query_string/language_service/lib/dql_language.ts @@ -11,16 +11,14 @@ export const getDQLLanguageConfig = (search: ISearchInterceptor): LanguageConfig id: 'kuery', title: 'DQL', search, + getQueryString(_) { + return ''; + }, searchBar: { - showDataSetsSelector: true, - showDataSourcesSelector: false, showQueryInput: true, showFilterBar: true, showDatePicker: true, showAutoRefreshOnly: false, - queryStringInput: { - initialValue: '', - }, }, fields: { filterable: true, diff --git a/src/plugins/data/public/query/query_string/language_service/lib/lucene_language.ts b/src/plugins/data/public/query/query_string/language_service/lib/lucene_language.ts index c22e194fac99..3b9643e92739 100644 --- a/src/plugins/data/public/query/query_string/language_service/lib/lucene_language.ts +++ b/src/plugins/data/public/query/query_string/language_service/lib/lucene_language.ts @@ -11,16 +11,14 @@ export const getLuceneLanguageConfig = (search: ISearchInterceptor): LanguageCon id: 'lucene', title: 'Lucene', search, + getQueryString(_) { + return ''; + }, searchBar: { - showDataSetsSelector: true, - showDataSourcesSelector: false, showQueryInput: true, showFilterBar: true, showDatePicker: true, showAutoRefreshOnly: false, - queryStringInput: { - initialValue: '', - }, }, fields: { filterable: true, diff --git a/src/plugins/data/public/query/query_string/language_service/types.ts b/src/plugins/data/public/query/query_string/language_service/types.ts index f434f8a81ac9..53bf397da3fa 100644 --- a/src/plugins/data/public/query/query_string/language_service/types.ts +++ b/src/plugins/data/public/query/query_string/language_service/types.ts @@ -4,24 +4,18 @@ */ import { ISearchInterceptor } from '../../../search'; +import { Query } from '../../../../public'; export interface LanguageConfig { id: string; title: string; search: ISearchInterceptor; - // Leave blank to support all data sources - // supportedDataSourceTypes?: Record; + getQueryString: (query: Query) => string; searchBar?: { - showDataSetsSelector?: boolean; - showDataSourcesSelector?: boolean; showQueryInput?: boolean; showFilterBar?: boolean; showDatePicker?: boolean; showAutoRefreshOnly?: boolean; - queryStringInput?: { - // will replace '' with the data source name - initialValue?: string; - }; dateRange?: { initialFrom?: string; initialTo?: string; diff --git a/src/plugins/data/public/query/query_string/query_string_manager.ts b/src/plugins/data/public/query/query_string/query_string_manager.ts index e75df28eb8ba..310c6981f001 100644 --- a/src/plugins/data/public/query/query_string/query_string_manager.ts +++ b/src/plugins/data/public/query/query_string/query_string_manager.ts @@ -148,12 +148,12 @@ export class QueryStringManager { const curQuery = this.query$.getValue(); const language = this.languageService.getLanguage(languageId); const dataset = curQuery.dataset; - const input = language?.searchBar?.queryStringInput?.initialValue || ''; + const input = language?.getQueryString(curQuery) || ''; return { - query: input || input.replace('', dataset?.title ?? ''), + query: input, language: languageId, - dataset: curQuery.dataset, + dataset, }; }; diff --git a/src/plugins/data/public/ui/query_editor/query_editor_top_row.tsx b/src/plugins/data/public/ui/query_editor/query_editor_top_row.tsx index 2482471d93a4..bbe99b5858da 100644 --- a/src/plugins/data/public/ui/query_editor/query_editor_top_row.tsx +++ b/src/plugins/data/public/ui/query_editor/query_editor_top_row.tsx @@ -13,7 +13,6 @@ import { prettyDuration, } from '@elastic/eui'; import classNames from 'classnames'; -import { isEqual } from 'lodash'; import React, { useState } from 'react'; import { createPortal } from 'react-dom'; import { IDataPluginServices, IIndexPattern, Query, TimeHistoryContract, TimeRange } from '../..'; diff --git a/src/plugins/query_enhancements/public/plugin.tsx b/src/plugins/query_enhancements/public/plugin.tsx index aead8dff3cc2..d09189eda3b9 100644 --- a/src/plugins/query_enhancements/public/plugin.tsx +++ b/src/plugins/query_enhancements/public/plugin.tsx @@ -16,7 +16,7 @@ import { QueryEnhancementsPluginStart, QueryEnhancementsPluginStartDependencies, } from './types'; -import { LanguageConfig } from '../../data/public'; +import { LanguageConfig, Query } from '../../data/public'; import { s3TypeConfig } from './datasets'; export class QueryEnhancementsPlugin @@ -61,15 +61,15 @@ export class QueryEnhancementsPlugin id: 'PPL', title: 'PPL', search: pplSearchInterceptor, + getQueryString: (query: Query) => { + return `source = ${query.dataset?.title}`; + }, searchBar: { - queryStringInput: { initialValue: 'source=' }, dateRange: { initialFrom: moment().subtract(2, 'days').toISOString(), initialTo: moment().add(2, 'days').toISOString(), }, showFilterBar: false, - showDataSetsSelector: true, - showDataSourcesSelector: true, }, fields: { filterable: false, @@ -85,12 +85,12 @@ export class QueryEnhancementsPlugin id: 'SQL', title: 'SQL', search: sqlSearchInterceptor, + getQueryString: (query: Query) => { + return `SELECT * FROM ${queryString.getQuery().dataset?.title} LIMIT 10`; + }, searchBar: { showDatePicker: false, showFilterBar: false, - showDataSetsSelector: true, - showDataSourcesSelector: true, - queryStringInput: { initialValue: 'SELECT * FROM LIMIT 10' }, }, fields: { filterable: false,