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 59c7eb174acd5..c3b396474cf92 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 @@ -66,6 +66,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 b329c24cab173..d1c7b446ef3fe 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 @@ -68,10 +68,12 @@ 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 additionalSuggestions = await additionalSourcesSuggestions( innerText, - sources, + timeSeriesSources, indexes.map(({ name }) => name), [] );