Skip to content

Commit ce38aa7

Browse files
committed
Merge branch 'main' of https://github.com/elastic/elasticsearch into esql-reranker-boostrap
2 parents ef82268 + c864c6c commit ce38aa7

File tree

5 files changed

+393
-24
lines changed

5 files changed

+393
-24
lines changed

server/src/main/java/org/elasticsearch/action/ResolvedIndices.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
import org.elasticsearch.action.search.SearchContextId;
1313
import org.elasticsearch.action.support.IndicesOptions;
14+
import org.elasticsearch.cluster.metadata.DataStream;
1415
import org.elasticsearch.cluster.metadata.IndexMetadata;
1516
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1617
import org.elasticsearch.cluster.metadata.ProjectMetadata;
1718
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1819
import org.elasticsearch.core.Nullable;
1920
import org.elasticsearch.index.Index;
2021
import org.elasticsearch.index.IndexNotFoundException;
22+
import org.elasticsearch.indices.InvalidIndexNameException;
2123
import org.elasticsearch.search.builder.PointInTimeBuilder;
2224
import org.elasticsearch.transport.RemoteClusterAware;
2325
import org.elasticsearch.transport.RemoteClusterService;
@@ -176,6 +178,20 @@ public static ResolvedIndices resolveWithIndexNamesAndOptions(
176178
? Index.EMPTY_ARRAY
177179
: indexNameExpressionResolver.concreteIndices(projectMetadata, localIndices, startTimeInMillis);
178180

181+
// prevent using selectors with remote cluster patterns
182+
if (DataStream.isFailureStoreFeatureFlagEnabled()) {
183+
for (final var indicesPerRemoteClusterAlias : remoteClusterIndices.entrySet()) {
184+
final String[] indices = indicesPerRemoteClusterAlias.getValue().indices();
185+
if (indices != null) {
186+
for (final String index : indices) {
187+
if (IndexNameExpressionResolver.hasSelectorSuffix(index)) {
188+
throw new InvalidIndexNameException(index, "Selectors are not yet supported on remote cluster patterns");
189+
}
190+
}
191+
}
192+
}
193+
}
194+
179195
return new ResolvedIndices(
180196
remoteClusterIndices,
181197
localIndices,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/stats/SearchContextStats.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ private SearchContextStats(List<SearchExecutionContext> contexts) {
8080
assert contexts != null && contexts.isEmpty() == false;
8181
}
8282

83-
public boolean exists(String field) {
84-
var stat = cache.computeIfAbsent(field, this::makeFieldStats);
85-
return stat.config.exists;
86-
}
87-
8883
private FieldStats makeFieldStats(String field) {
8984
var stat = new FieldStats();
9085
stat.config = makeFieldConfig(field);
@@ -123,19 +118,30 @@ private FieldConfig makeFieldConfig(String field) {
123118
}
124119
}
125120

121+
private boolean fastNoCacheFieldExists(String field) {
122+
for (SearchExecutionContext context : contexts) {
123+
if (context.isFieldMapped(field)) {
124+
return true;
125+
}
126+
}
127+
return false;
128+
}
129+
130+
public boolean exists(String field) {
131+
var stat = cache.get(field);
132+
return stat != null ? stat.config.exists : fastNoCacheFieldExists(field);
133+
}
134+
126135
public boolean isIndexed(String field) {
127-
var stat = cache.computeIfAbsent(field, this::makeFieldStats);
128-
return stat.config.indexed;
136+
return cache.computeIfAbsent(field, this::makeFieldStats).config.indexed;
129137
}
130138

131139
public boolean hasDocValues(String field) {
132-
var stat = cache.computeIfAbsent(field, this::makeFieldStats);
133-
return stat.config.hasDocValues;
140+
return cache.computeIfAbsent(field, this::makeFieldStats).config.hasDocValues;
134141
}
135142

136143
public boolean hasExactSubfield(String field) {
137-
var stat = cache.computeIfAbsent(field, this::makeFieldStats);
138-
return stat.config.hasExactSubfield;
144+
return cache.computeIfAbsent(field, this::makeFieldStats).config.hasExactSubfield;
139145
}
140146

141147
public long count() {
@@ -218,7 +224,7 @@ public boolean isSingleValue(String field) {
218224
var stat = cache.computeIfAbsent(field, this::makeFieldStats);
219225
if (stat.singleValue == null) {
220226
// there's no such field so no need to worry about multi-value fields
221-
if (exists(field) == false) {
227+
if (stat.config.exists == false) {
222228
stat.singleValue = true;
223229
} else {
224230
// fields are MV per default

0 commit comments

Comments
 (0)