Skip to content

Commit 3c9fadb

Browse files
authored
[ES|QL] Fixes the autocomplete of timeseries sources after comma (#241402)
## Summary Fixes the suggestions of timeseries (instead of all indices) in TS command after one selected <img width="580" height="145" alt="image" src="https://github.com/user-attachments/assets/0964262d-b0f7-43b9-93c5-18cec644bd96" /> ### Checklist - [ ] [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
1 parent de836ed commit 3c9fadb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ describe('TS Autocomplete', () => {
8181
]);
8282
});
8383

84+
test('can suggest timeseries after one already selected', async () => {
85+
const suggestions = await suggest('TS timeseries_index, ');
86+
const labels = suggestions.map((s) => s.label);
87+
88+
expect(labels).toEqual(['timeseries_index_with_alias', 'time_series_index']);
89+
});
90+
8491
test('discriminates between indices and aliases', async () => {
8592
const suggestions = await suggest('TS ');
8693
const indices: string[] = suggestions

src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ export async function autocomplete(
7474
// TS something/
7575
// TS something, /
7676
else if (indexes.length) {
77-
const sources = context?.sources ?? [];
77+
const timeSeriesSources =
78+
context?.timeSeriesSources?.map(({ name }) => ({ name, hidden: false })) ?? [];
7879
const recommendedQuerySuggestions = await getRecommendedQueriesSuggestions(
7980
context?.editorExtensions ?? { recommendedFields: [], recommendedQueries: [] }
8081
);
8182
const additionalSuggestions = await additionalSourcesSuggestions(
8283
innerText,
83-
sources,
84+
timeSeriesSources,
8485
indexes.map(({ name }) => name),
8586
recommendedQuerySuggestions
8687
);

0 commit comments

Comments
 (0)