Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/changelog/135601.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pr: 135601
summary: ES|QL Empty index resolution
area: ES|QL
type: breaking
issues: []
breaking:
title: ES|QL Empty index resolution
area: ES|QL
details: Please describe the details of this change for the release notes. You can
use asciidoc.
impact: Please describe the impact of this change to users
notable: false
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ public void testDoesNotResolveMissingIndex() {
);
}

public void testDoesNotResolveEmptyPattern() {
expectThrows(
VerificationException.class,
containsString("Unknown index [index-*]"),
() -> run(syncEsqlQueryRequest().query("FROM index-*"))
);
public void testResolveEmptyPattern() {
assertAcked(client().admin().indices().prepareCreate("data"));
indexRandom(true, "data", 1);

try (var response = run(syncEsqlQueryRequest().query("FROM data,index-* METADATA _index"))) {
assertOk(response);
assertResultConcreteIndices(response, "data");
}
try (var response = run(syncEsqlQueryRequest().query("FROM index-* METADATA _index"))) {
assertOk(response);
assertResultConcreteIndices(response);
}
}

public void testDoesNotResolveClosedIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public static IndexResolution invalid(String invalid) {
return new IndexResolution(null, invalid, Set.of(), Map.of());
}

public static IndexResolution notFound(String name) {
Objects.requireNonNull(name, "name must not be null");
return invalid("Unknown index [" + name + "]");
public static IndexResolution empty(String indexPattern) {
return IndexResolution.valid(new EsIndex(indexPattern, Map.of(), Map.of()));
}

private final EsIndex index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,7 @@ private void preAnalyzeMainIndices(
String indexExpressionToResolve = EsqlCCSUtils.createIndexExpressionFromAvailableClusters(executionInfo);
if (indexExpressionToResolve.isEmpty()) {
// if this was a pure remote CCS request (no local indices) and all remotes are offline, return an empty IndexResolution
listener.onResponse(
result.withIndices(IndexResolution.valid(new EsIndex(preAnalysis.indexPattern().indexPattern(), Map.of(), Map.of())))
);
listener.onResponse(result.withIndices(IndexResolution.empty(preAnalysis.indexPattern().indexPattern())));
} else {
indexResolver.resolveAsMergedMapping(
indexExpressionToResolve,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static IndexResolution mergedMappings(String indexPattern, FieldsInfo fie
assert ThreadPool.assertCurrentThreadPool(ThreadPool.Names.SEARCH_COORDINATION); // too expensive to run this on a transport worker
int numberOfIndices = fieldsInfo.caps.getIndexResponses().size();
if (numberOfIndices == 0) {
return IndexResolution.notFound(indexPattern);
return IndexResolution.empty(indexPattern);
}

// For each field name, store a list of the field caps responses from each index
Expand Down