diff --git a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts index 05f97e0fddc66..b6e8c41c4dcb1 100644 --- a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts +++ b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts @@ -81,6 +81,13 @@ describe('TS Autocomplete', () => { ]); }); + test('can suggest timeseries after one already selected', async () => { + const suggestions = await suggest('TS timeseries_index, '); + const labels = suggestions.map((s) => s.label); + + expect(labels).toEqual(['timeseries_index_with_alias', 'time_series_index']); + }); + test('discriminates between indices and aliases', async () => { const suggestions = await suggest('TS '); const indices: string[] = suggestions diff --git a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts index a7158f2257b28..a152b175eaf10 100644 --- a/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts +++ b/src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts @@ -74,13 +74,14 @@ export async function autocomplete( // TS something/ // TS something, / else if (indexes.length) { - const sources = context?.sources ?? []; + const timeSeriesSources = + context?.timeSeriesSources?.map(({ name }) => ({ name, hidden: false })) ?? []; const recommendedQuerySuggestions = await getRecommendedQueriesSuggestions( context?.editorExtensions ?? { recommendedFields: [], recommendedQueries: [] } ); const additionalSuggestions = await additionalSourcesSuggestions( innerText, - sources, + timeSeriesSources, indexes.map(({ name }) => name), recommendedQuerySuggestions );