Skip to content

Commit 99fc31d

Browse files
Merge branch 'main' into subquery-in-from
2 parents 079f403 + 9467036 commit 99fc31d

File tree

26 files changed

+1623
-1628
lines changed

26 files changed

+1623
-1628
lines changed

docs/changelog/135897.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135897
2+
summary: Apply source excludes early when retrieving the `_inference_fields`
3+
area: Search
4+
type: bug
5+
issues: []

docs/changelog/135901.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135901
2+
summary: Add support for dot-separated attribute names (e.g. `foo.bar`) and for parameters (e.g. `??my_param`) in FUSE GROUP BY
3+
area: ES|QL
4+
type: bug
5+
issues: []

docs/reference/elasticsearch/index-lifecycle-actions/ilm-downsample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mapped_pages:
77

88
Phases allowed: hot, warm, cold.
99

10-
Aggregates a time series (TSDS) index and stores pre-computed statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) for each metric field grouped by a configured time interval. For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index. All documents within an hour interval are summarized and stored as a single document and stored in the downsample index.
10+
Aggregates a time series (TSDS) index and stores pre-computed statistical summaries (`min`, `max`, `sum`, and `value_count`) for each metric field grouped by a configured time interval. For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index. All documents within an hour interval are summarized and stored as a single document and stored in the downsample index.
1111

1212
This action corresponds to the [downsample API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-downsample).
1313

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.io.IOException;
2525
import java.util.List;
26+
import java.util.Optional;
2627
import java.util.Set;
2728
import java.util.function.Predicate;
2829

@@ -38,10 +39,12 @@ public class RestSearchTemplateAction extends BaseRestHandler {
3839

3940
private final Predicate<NodeFeature> clusterSupportsFeature;
4041
private final Settings settings;
42+
private final boolean inCpsContext;
4143

4244
public RestSearchTemplateAction(Predicate<NodeFeature> clusterSupportsFeature, Settings settings) {
4345
this.clusterSupportsFeature = clusterSupportsFeature;
4446
this.settings = settings;
47+
this.inCpsContext = settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false);
4548
}
4649

4750
@Override
@@ -61,7 +64,7 @@ public String getName() {
6164

6265
@Override
6366
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
64-
if (settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false)) {
67+
if (inCpsContext) {
6568
// accept but drop project_routing param until fully supported
6669
request.param("project_routing");
6770
}
@@ -73,7 +76,9 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client
7376
request,
7477
null,
7578
clusterSupportsFeature,
76-
size -> searchRequest.source().size(size)
79+
size -> searchRequest.source().size(size),
80+
// This endpoint is CPS-enabled so propagate the right value.
81+
Optional.of(inCpsContext)
7782
);
7883

7984
// Creates the search template request

modules/reindex/src/main/java/org/elasticsearch/reindex/AbstractBulkByQueryRestHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import java.io.IOException;
2828
import java.util.Map;
29+
import java.util.Optional;
2930
import java.util.function.Consumer;
3031
import java.util.function.Predicate;
3132

@@ -52,7 +53,14 @@ protected void parseInternalRequest(
5253
SearchRequest searchRequest = internal.getSearchRequest();
5354

5455
try (XContentParser parser = extractRequestSpecificFields(restRequest, bodyConsumers)) {
55-
RestSearchAction.parseSearchRequest(searchRequest, restRequest, parser, clusterSupportsFeature, size -> failOnSizeSpecified());
56+
RestSearchAction.parseSearchRequest(
57+
searchRequest,
58+
restRequest,
59+
parser,
60+
clusterSupportsFeature,
61+
size -> failOnSizeSpecified(),
62+
Optional.empty()
63+
);
5664
}
5765

5866
searchRequest.source().size(restRequest.paramAsInt("scroll_size", searchRequest.source().size()));

muted-tests.yml

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,6 @@ tests:
504504
- class: org.elasticsearch.repositories.blobstore.testkit.analyze.MinioRepositoryAnalysisRestIT
505505
method: testRepositoryAnalysis
506506
issue: https://github.com/elastic/elasticsearch/issues/134853
507-
- class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT
508-
method: testStopQueryInlinestats
509-
issue: https://github.com/elastic/elasticsearch/issues/134854
510507
- class: org.elasticsearch.xpack.esql.action.CrossClusterCancellationIT
511508
method: testCancelSkipUnavailable
512509
issue: https://github.com/elastic/elasticsearch/issues/134865
@@ -522,9 +519,6 @@ tests:
522519
- class: org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT
523520
method: test {csv-spec:stats.CountDistinctWithConditions}
524521
issue: https://github.com/elastic/elasticsearch/issues/134993
525-
- class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT
526-
method: testStopQueryInlineStats
527-
issue: https://github.com/elastic/elasticsearch/issues/135032
528522
- class: org.elasticsearch.xpack.esql.ccq.MultiClusterSpecIT
529523
method: test {csv-spec:fork.ForkBeforeStatsWithWhere}
530524
issue: https://github.com/elastic/elasticsearch/issues/135041
@@ -648,6 +642,66 @@ tests:
648642
- class: org.elasticsearch.upgrades.FullClusterRestartIT
649643
method: testSystemIndexMetadataIsUpgraded {cluster=UPGRADED}
650644
issue: https://github.com/elastic/elasticsearch/issues/135923
645+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
646+
method: testSearch {cluster=UPGRADED}
647+
issue: https://github.com/elastic/elasticsearch/issues/135927
648+
- class: org.elasticsearch.xpack.inference.chunking.ChunkingSettingsBuilderTests
649+
method: testBuildChunkingSettingsForElasticReranker_QueryTokenCountLessThanHalfOfTokenLimit
650+
issue: https://github.com/elastic/elasticsearch/issues/135928
651+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
652+
method: testPeerRecoveryRetentionLeases {cluster=UPGRADED}
653+
issue: https://github.com/elastic/elasticsearch/issues/135929
654+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
655+
method: testPersianAnalyzerBWC {cluster=UPGRADED}
656+
issue: https://github.com/elastic/elasticsearch/issues/135930
657+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
658+
method: testSnapshotRestore {cluster=UPGRADED}
659+
issue: https://github.com/elastic/elasticsearch/issues/135933
660+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
661+
method: testForbidDisableSoftDeletesOnRestore {cluster=UPGRADED}
662+
issue: https://github.com/elastic/elasticsearch/issues/135937
663+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
664+
method: testShrinkAfterUpgrade {cluster=UPGRADED}
665+
issue: https://github.com/elastic/elasticsearch/issues/135938
666+
- class: org.elasticsearch.xpack.esql.action.EsqlActionBreakerIT
667+
method: testTopNPushedToLuceneOnSortedIndex
668+
issue: https://github.com/elastic/elasticsearch/issues/135939
669+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
670+
method: testClosedIndices {cluster=UPGRADED}
671+
issue: https://github.com/elastic/elasticsearch/issues/135941
672+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
673+
method: testOperationBasedRecovery {cluster=UPGRADED}
674+
issue: https://github.com/elastic/elasticsearch/issues/135944
675+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
676+
method: testRomanianAnalyzerBWC {cluster=UPGRADED}
677+
issue: https://github.com/elastic/elasticsearch/issues/135948
678+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
679+
method: testEmptyShard {cluster=UPGRADED}
680+
issue: https://github.com/elastic/elasticsearch/issues/135951
681+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
682+
method: testRollover {cluster=UPGRADED}
683+
issue: https://github.com/elastic/elasticsearch/issues/135952
684+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
685+
method: testRecovery {cluster=UPGRADED}
686+
issue: https://github.com/elastic/elasticsearch/issues/135953
687+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
688+
method: testNewReplicas {cluster=UPGRADED}
689+
issue: https://github.com/elastic/elasticsearch/issues/135956
690+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
691+
method: testHistoryUUIDIsAdded {cluster=UPGRADED}
692+
issue: https://github.com/elastic/elasticsearch/issues/135957
693+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
694+
method: testTurnOffTranslogRetentionAfterUpgraded {cluster=UPGRADED}
695+
issue: https://github.com/elastic/elasticsearch/issues/135958
696+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
697+
method: testSoftDeletes {cluster=UPGRADED}
698+
issue: https://github.com/elastic/elasticsearch/issues/135959
699+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
700+
method: testClusterState {cluster=UPGRADED}
701+
issue: https://github.com/elastic/elasticsearch/issues/135960
702+
- class: org.elasticsearch.upgrades.FullClusterRestartIT
703+
method: testShrink {cluster=UPGRADED}
704+
issue: https://github.com/elastic/elasticsearch/issues/135962
651705

652706
# Examples:
653707
#

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static TransportVersion def(int id) {
5353
}
5454

5555
// TODO: ES-10337 we can remove all transport versions earlier than 8.18
56-
public static final TransportVersion V_7_0_0 = def(7_00_00_99);
5756
public static final TransportVersion V_7_1_0 = def(7_01_00_99);
5857
public static final TransportVersion V_7_2_0 = def(7_02_00_99);
5958
public static final TransportVersion V_7_3_0 = def(7_03_00_99);

server/src/main/java/org/elasticsearch/index/get/ShardGetService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ private static Boolean shouldExcludeVectorsFromSourceExplicit(FetchSourceContext
426426

427427
public static boolean shouldExcludeInferenceFieldsFromSource(IndexSettings indexSettings, FetchSourceContext fetchSourceContext) {
428428
var explicit = shouldExcludeInferenceFieldsFromSourceExplicit(fetchSourceContext);
429+
var filter = fetchSourceContext != null ? fetchSourceContext.filter() : null;
430+
if (filter != null) {
431+
if (filter.isPathFiltered(InferenceMetadataFieldsMapper.NAME, true)) {
432+
return true;
433+
} else if (filter.isExplicitlyIncluded(InferenceMetadataFieldsMapper.NAME)) {
434+
return false;
435+
}
436+
}
429437
return explicit != null ? explicit : INDEX_MAPPING_EXCLUDE_SOURCE_VECTORS_SETTING.get(indexSettings.getSettings());
430438
}
431439

server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.util.Arrays;
4444
import java.util.List;
4545
import java.util.Locale;
46+
import java.util.Optional;
4647
import java.util.Set;
4748
import java.util.function.IntConsumer;
4849
import java.util.function.Predicate;
@@ -68,6 +69,7 @@ public class RestSearchAction extends BaseRestHandler {
6869
private final SearchUsageHolder searchUsageHolder;
6970
private final Predicate<NodeFeature> clusterSupportsFeature;
7071
private final Settings settings;
72+
private final boolean inCpsContext;
7173

7274
public RestSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeature> clusterSupportsFeature) {
7375
this(searchUsageHolder, clusterSupportsFeature, null);
@@ -77,6 +79,7 @@ public RestSearchAction(SearchUsageHolder searchUsageHolder, Predicate<NodeFeatu
7779
this.searchUsageHolder = searchUsageHolder;
7880
this.clusterSupportsFeature = clusterSupportsFeature;
7981
this.settings = settings;
82+
this.inCpsContext = settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false);
8083
}
8184

8285
@Override
@@ -109,7 +112,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
109112
// this might be set by old clients
110113
request.param("min_compatible_shard_node");
111114

112-
if (settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false)) {
115+
if (inCpsContext) {
113116
// accept but drop project_routing param until fully supported
114117
request.param("project_routing");
115118
}
@@ -128,7 +131,16 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
128131
*/
129132
IntConsumer setSize = size -> searchRequest.source().size(size);
130133
request.withContentOrSourceParamParserOrNull(
131-
parser -> parseSearchRequest(searchRequest, request, parser, clusterSupportsFeature, setSize, searchUsageHolder)
134+
parser -> parseSearchRequest(
135+
searchRequest,
136+
request,
137+
parser,
138+
clusterSupportsFeature,
139+
setSize,
140+
searchUsageHolder,
141+
// This endpoint is CPS-enabled so propagate the right value.
142+
Optional.of(inCpsContext)
143+
)
132144
);
133145

134146
return channel -> {
@@ -146,15 +158,23 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
146158
* parameter
147159
* @param clusterSupportsFeature used to check if certain features are available in this cluster
148160
* @param setSize how the size url parameter is handled. {@code udpate_by_query} and regular search differ here.
161+
* @param inCpsContext specifies if we're in CPS context.
162+
* <br>
163+
* true - the endpoint that's invoking this method is CPS-enabled and in a CPS/Serverless context.
164+
* <br>
165+
* false - the endpoint that's invoking this method is CPS-enabled but not in a CPS/Serverless context.
166+
* <br>
167+
* Optional.empty - the endpoint is not CPS-enabled irrespective of the environment.
149168
*/
150169
public static void parseSearchRequest(
151170
SearchRequest searchRequest,
152171
RestRequest request,
153172
XContentParser requestContentParser,
154173
Predicate<NodeFeature> clusterSupportsFeature,
155-
IntConsumer setSize
174+
IntConsumer setSize,
175+
Optional<Boolean> inCpsContext
156176
) throws IOException {
157-
parseSearchRequest(searchRequest, request, requestContentParser, clusterSupportsFeature, setSize, null);
177+
parseSearchRequest(searchRequest, request, requestContentParser, clusterSupportsFeature, setSize, null, inCpsContext);
158178
}
159179

160180
/**
@@ -167,14 +187,22 @@ public static void parseSearchRequest(
167187
* @param clusterSupportsFeature used to check if certain features are available in this cluster
168188
* @param setSize how the size url parameter is handled. {@code udpate_by_query} and regular search differ here.
169189
* @param searchUsageHolder the holder of search usage stats
190+
* @param inCpsContext specifies if we're in CPS context.
191+
* <br>
192+
* true - the endpoint that's invoking this method is CPS-enabled and in a CPS/Serverless context.
193+
* <br>
194+
* false - the endpoint that's invoking this method is CPS-enabled but not in a CPS/Serverless context.
195+
* <br>
196+
* Optional.empty - the endpoint is not CPS-enabled irrespective of the environment.
170197
*/
171198
public static void parseSearchRequest(
172199
SearchRequest searchRequest,
173200
RestRequest request,
174201
@Nullable XContentParser requestContentParser,
175202
Predicate<NodeFeature> clusterSupportsFeature,
176203
IntConsumer setSize,
177-
@Nullable SearchUsageHolder searchUsageHolder
204+
@Nullable SearchUsageHolder searchUsageHolder,
205+
Optional<Boolean> inCpsContext
178206
) throws IOException {
179207
if (searchRequest.source() == null) {
180208
searchRequest.source(new SearchSourceBuilder());
@@ -229,9 +257,17 @@ public static void parseSearchRequest(
229257
if (searchRequest.pointInTimeBuilder() != null) {
230258
preparePointInTime(searchRequest, request);
231259
} else {
232-
searchRequest.setCcsMinimizeRoundtrips(
233-
request.paramAsBoolean("ccs_minimize_roundtrips", searchRequest.isCcsMinimizeRoundtrips())
234-
);
260+
if (inCpsContext.orElse(false)) {
261+
// We're in CPS environment. MRT should not be settable by the user.
262+
if (request.hasParam("ccs_minimize_roundtrips")) {
263+
throw new IllegalArgumentException("Setting ccs_minimize_roundtrips is not supported in cross-project search context");
264+
}
265+
} else {
266+
// Either we're in non-CPS environment or the endpoint isn't CPS enabled, so parse what's in the request.
267+
searchRequest.setCcsMinimizeRoundtrips(
268+
request.paramAsBoolean("ccs_minimize_roundtrips", searchRequest.isCcsMinimizeRoundtrips())
269+
);
270+
}
235271
}
236272
if (request.paramAsBoolean("force_synthetic_source", false)) {
237273
searchRequest.setForceSyntheticSource(true);

server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourcePhase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.search.lookup.Source;
2020
import org.elasticsearch.search.lookup.SourceFilter;
2121

22+
import java.util.HashMap;
2223
import java.util.Map;
2324

2425
public final class FetchSourcePhase implements FetchSubPhase {
@@ -99,6 +100,10 @@ private Source replaceInferenceMetadataFields(SearchHit hit, Source source) {
99100
return source;
100101
}
101102
var newSource = source.source();
103+
if (newSource instanceof HashMap == false) {
104+
// the map is not mutable
105+
newSource = new HashMap<>(newSource);
106+
}
102107
newSource.put(InferenceMetadataFieldsMapper.NAME, field.getValues().get(0));
103108
return Source.fromMap(newSource, source.sourceContentType());
104109
}

0 commit comments

Comments
 (0)