Skip to content

Commit 89b5ad9

Browse files
committed
add supported fields to coordinator rewriter
1 parent 6601b76 commit 89b5ad9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

server/src/main/java/org/elasticsearch/index/query/CoordinatorRewriteContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.common.regex.Regex;
1818
import org.elasticsearch.core.Nullable;
1919
import org.elasticsearch.index.mapper.ConstantFieldType;
20+
import org.elasticsearch.index.mapper.IndexFieldMapper;
2021
import org.elasticsearch.index.mapper.MappedFieldType;
2122
import org.elasticsearch.index.mapper.MappingLookup;
2223
import org.elasticsearch.index.mapper.ValueFetcher;
@@ -26,6 +27,7 @@
2627

2728
import java.util.Collections;
2829
import java.util.Map;
30+
import java.util.Set;
2931
import java.util.function.LongSupplier;
3032

3133
/**
@@ -39,6 +41,13 @@ public class CoordinatorRewriteContext extends QueryRewriteContext {
3941

4042
public static final String TIER_FIELD_NAME = "_tier";
4143

44+
public static final Set<String> SUPPORTED_FIELDS = Set.of(
45+
DataStream.TIMESTAMP_FIELD_NAME,
46+
IndexMetadata.EVENT_INGESTED_FIELD_NAME,
47+
TIER_FIELD_NAME,
48+
IndexFieldMapper.NAME
49+
);
50+
4251
static final ConstantFieldType TIER_FIELD_TYPE = new ConstantFieldType(TIER_FIELD_NAME, Map.of()) {
4352
@Override
4453
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.core.Tuple;
1717
import org.elasticsearch.index.IndexMode;
1818
import org.elasticsearch.index.mapper.MappedFieldType;
19+
import org.elasticsearch.index.query.CoordinatorRewriteContext;
1920
import org.elasticsearch.index.query.QueryBuilder;
2021
import org.elasticsearch.index.query.SearchExecutionContext;
2122
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
@@ -182,11 +183,8 @@ public static PhysicalPlan localPlan(
182183
/**
183184
* Extracts a filter that can be used to skip unmatched shards on the coordinator.
184185
*/
185-
private static final Set<String> CAN_MATCH_FIELDS = Set.of("@timestamp", "event.ingested");
186-
187186
public static QueryBuilder canMatchFilter(PhysicalPlan plan) {
188-
// metadata field like _index, _tier
189-
return detectFilter(plan, f -> CAN_MATCH_FIELDS.contains(f) || f.startsWith("_"));
187+
return detectFilter(plan, CoordinatorRewriteContext.SUPPORTED_FIELDS::contains);
190188
}
191189

192190
/**

0 commit comments

Comments
 (0)