feat(elasticsearch): add SQL-model execution with mapping-aware completion

- Route SELECT * FROM <index> through /_search for simple browses; aggregates/projections stay on /_sql
- Drive completion columns from /_mapping (flattened dotted fields, multi-fields)
- Switch editor completion to SQL when the active statement starts with SELECT/WITH on ES
- Skip generic SQL semantic diagnostics for ES (hyphenated wildcard indices caused 500s)
- Wire ES into server-side pagination plan; derive completion context from line blocks
- Fix result-grid pagination exceeding in-memory result sets (allRowsLoaded)
This commit is contained in:
Yong Studt authored and GitHub committed 2026-06-08 17:53:05 +08:00
1 parent 465ed195cf
commit 2628fb8374
11 files changed
+749 -26

No files matched your search

@@ -29,6 +29,7 @@ import {
getSqlFunctionSignatureHelp,
getSqlCompletionContext,
getSqlCompletionResultValidFor,
isSqlLikeCompletionStatement,
shouldAutoOpenSqlCompletion,
extractCteDefinitions,
} from "@/lib/sqlCompletion";
@@ -739,7 +740,13 @@ async function refreshSemanticDiagnostics() {
setSemanticDiagnostics([]);
return;
}
if (!shouldRunSqlSemanticDiagnostics(sql, currentView.state.selection.main.head)) {
if (props.databaseType === "elasticsearch") {
setSemanticDiagnostics([]);
return;
}
if (
!shouldRunSqlSemanticDiagnostics(sql, currentView.state.selection.main.head, { databaseType: props.databaseType })
) {
scheduleSemanticDiagnostics(1200);
return;
}
@@ -933,15 +940,17 @@ async function provideSqlCompletions(
explicit: boolean,
) {
if (!props.connectionId) return null;
const fullDoc = currentState.doc.toString();
if (props.databaseType === "elasticsearch") {
return provideElasticsearchCompletions(currentState, position, explicit);
if (!isSqlLikeCompletionStatement(fullDoc, position)) {
return provideElasticsearchCompletions(currentState, position, explicit);
}
}
const hasDatabase = props.database != null;
const epoch = ++completionEpoch;
try {
const fullDoc = currentState.doc.toString();
if (!explicit && !shouldAutoOpenSqlCompletion(fullDoc, position)) return null;
const completionContext = getSqlCompletionContext(fullDoc, position);