forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ES|QL] Recommended queries (elastic#194418)
## Summary Closes elastic#187325 <img width="927" alt="image" src="https://github.com/user-attachments/assets/46220c26-f54c-4bd7-9a8b-d1d29591dc68"> <img width="539" alt="image" src="https://github.com/user-attachments/assets/f4d938af-f2b6-400d-918f-3dcf1d22618f"> This is the first iteration of this feature. We want to help the users familiarize themselves with popular operations. This PR: - adds the recommended queries list in the help menu of unified search - adds the list after the users select a datasource with the from command - adds the list in the editor's empty state ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
Showing
16 changed files
with
424 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ages/kbn-esql-validation-autocomplete/src/autocomplete/recommended_queries/suggestions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import type { SuggestionRawDefinition, GetFieldsByTypeFn } from '../types'; | ||
import { getRecommendedQueries } from './templates'; | ||
|
||
export const getRecommendedQueriesSuggestions = async ( | ||
getFieldsByType: GetFieldsByTypeFn, | ||
fromCommand: string = '' | ||
): Promise<SuggestionRawDefinition[]> => { | ||
const fieldSuggestions = await getFieldsByType('date', [], { | ||
openSuggestions: true, | ||
}); | ||
let timeField = ''; | ||
if (fieldSuggestions.length) { | ||
timeField = | ||
fieldSuggestions?.find((field) => field.label === '@timestamp')?.label || | ||
fieldSuggestions[0].label; | ||
} | ||
|
||
const recommendedQueries = getRecommendedQueries({ fromCommand, timeField }); | ||
|
||
const suggestions: SuggestionRawDefinition[] = recommendedQueries.map((query) => { | ||
return { | ||
label: query.label, | ||
text: query.queryString, | ||
kind: 'Issue', | ||
detail: query.description, | ||
sortText: 'D', | ||
}; | ||
}); | ||
|
||
return suggestions; | ||
}; |
Oops, something went wrong.