Skip to content

Commit 95dbf05

Browse files
Merge branch 'main' into esql_split_docs_pages_functions_operators
2 parents c349f28 + 4fe2fb5 commit 95dbf05

File tree

75 files changed

+2280
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2280
-522
lines changed

docs/changelog/126009.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126009
2+
summary: Change ModelLoaderUtils.split to return the correct number of chunks and ranges.
3+
area: Machine Learning
4+
type: bug
5+
issues:
6+
- 121799

docs/changelog/126385.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126385
2+
summary: Filter out empty top docs results before merging
3+
area: Search
4+
type: bug
5+
issues:
6+
- 126118

docs/changelog/126493.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126493
2+
summary: Bedrock Cohere Task Settings Support
3+
area: Machine Learning
4+
type: enhancement
5+
issues:
6+
- 126156

docs/changelog/126550.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126550
2+
summary: Add leniency to missing array values in mustache
3+
area: Infra/Scripting
4+
type: bug
5+
issues:
6+
- 55200

docs/reference/elasticsearch/configuration-reference/enrich-settings.md

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

88
# Enrich settings [enrich_settings]
99

10-
You can configure these enrich settings in the `elasticsearch.yml` file. For more information, see [Set up an enrich processor](docs-content:///manage-data/ingest/transform-enrich/set-up-an-enrich-processor.md).
10+
You can configure these enrich settings in the `elasticsearch.yml` file. For more information, see [Set up an enrich processor](docs-content://manage-data/ingest/transform-enrich/set-up-an-enrich-processor.md).
1111

1212
`enrich.cache_size` ![logo cloud](https://doc-icons.s3.us-east-2.amazonaws.com/logo_cloud.svg "Supported on Elastic Cloud Hosted")
1313
: Maximum number of searches to cache for enriching documents. Defaults to 1000. There is a single cache for all enrich processors in the cluster. This setting determines the size of that cache.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ public Object get(Object key) {
111111
if ("size".equals(key)) {
112112
return size();
113113
} else if (key instanceof Number number) {
114-
return Array.get(array, number.intValue());
114+
return number.intValue() >= 0 && number.intValue() < length ? Array.get(array, number.intValue()) : null;
115115
}
116116
try {
117117
int index = Integer.parseInt(key.toString());
118-
return Array.get(array, index);
118+
return index >= 0 && index < length ? Array.get(array, index) : null;
119119
} catch (NumberFormatException nfe) {
120120
// if it's not a number it is as if the key doesn't exist
121121
return null;
@@ -169,11 +169,11 @@ public Object get(Object key) {
169169
if ("size".equals(key)) {
170170
return col.size();
171171
} else if (key instanceof Number number) {
172-
return Iterables.get(col, number.intValue());
172+
return number.intValue() >= 0 && number.intValue() < col.size() ? Iterables.get(col, number.intValue()) : null;
173173
}
174174
try {
175175
int index = Integer.parseInt(key.toString());
176-
return Iterables.get(col, index);
176+
return index >= 0 && index < col.size() ? Iterables.get(col, index) : null;
177177
} catch (NumberFormatException nfe) {
178178
// if it's not a number it is as if the key doesn't exist
179179
return null;

modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@ public void testMapInArrayAccess() throws Exception {
141141
assertThat(output, both(containsString("foo")).and(containsString("bar")));
142142
}
143143

144+
public void testMapInArrayBadAccess() throws Exception {
145+
String template = "{{data.0.key}} {{data.2.key}}";
146+
TemplateScript.Factory factory = engine.compile(null, template, TemplateScript.CONTEXT, Collections.emptyMap());
147+
Map<String, Object> vars = new HashMap<>();
148+
vars.put("data", new Object[] { singletonMap("key", "foo"), singletonMap("key", "bar") });
149+
// assertThat(factory.newInstance(vars).execute(), equalTo("foo "));
150+
151+
vars.put("data", Arrays.asList(singletonMap("key", "foo"), singletonMap("key", "bar")));
152+
factory.newInstance(vars);
153+
assertThat(factory.newInstance(vars).execute(), equalTo("foo "));
154+
155+
// HashSet iteration order isn't fixed
156+
Set<Object> setData = new HashSet<>();
157+
setData.add(singletonMap("key", "foo"));
158+
setData.add(singletonMap("key", "bar"));
159+
vars.put("data", setData);
160+
String output = factory.newInstance(vars).execute();
161+
assertThat(output, both(containsString("foo")).and(not(containsString("bar"))));
162+
}
163+
144164
public void testSizeAccessForCollectionsAndArrays() throws Exception {
145165
String[] randomArrayValues = generateRandomStringArray(10, 20, false);
146166
List<String> randomList = Arrays.asList(generateRandomStringArray(10, 20, false));

modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureBlobStoreRepositoryTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.nio.charset.StandardCharsets;
4949
import java.nio.file.NoSuchFileException;
5050
import java.util.ArrayList;
51+
import java.util.Arrays;
5152
import java.util.Base64;
5253
import java.util.Collection;
5354
import java.util.Collections;
@@ -241,7 +242,7 @@ protected String requestUniqueId(final HttpExchange exchange) {
241242
private static class AzureHTTPStatsCollectorHandler extends HttpStatsCollectorHandler {
242243

243244
private AzureHTTPStatsCollectorHandler(HttpHandler delegate) {
244-
super(delegate);
245+
super(delegate, Arrays.stream(AzureBlobStore.Operation.values()).map(AzureBlobStore.Operation::getKey).toArray(String[]::new));
245246
}
246247

247248
@Override

modules/repository-gcs/src/internalClusterTest/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStoreRepositoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ protected boolean canFailRequest(final HttpExchange exchange) {
364364
private static class GoogleCloudStorageStatsCollectorHttpHandler extends HttpStatsCollectorHandler {
365365

366366
GoogleCloudStorageStatsCollectorHttpHandler(final HttpHandler delegate) {
367-
super(delegate);
367+
super(delegate, Arrays.stream(StorageOperation.values()).map(StorageOperation::key).toArray(String[]::new));
368368
}
369369

370370
@Override

modules/repository-s3/qa/third-party/src/test/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,56 @@ public void testReadFromPositionLargerThanBlobLength() {
228228
e -> asInstanceOf(AmazonS3Exception.class, e.getCause()).getStatusCode() == RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()
229229
);
230230
}
231+
232+
public void testCopy() {
233+
final var sourceBlobName = randomIdentifier();
234+
final var blobBytes = randomBytesReference(randomIntBetween(100, 2_000));
235+
final var destinationBlobName = randomIdentifier();
236+
237+
final var repository = getRepository();
238+
239+
final var targetBytes = executeOnBlobStore(repository, sourceBlobContainer -> {
240+
sourceBlobContainer.writeBlob(randomPurpose(), sourceBlobName, blobBytes, true);
241+
242+
final var destinationBlobContainer = repository.blobStore().blobContainer(repository.basePath().add("target"));
243+
destinationBlobContainer.copyBlob(
244+
randomPurpose(),
245+
sourceBlobContainer,
246+
sourceBlobName,
247+
destinationBlobName,
248+
blobBytes.length()
249+
);
250+
251+
return destinationBlobContainer.readBlob(randomPurpose(), destinationBlobName).readAllBytes();
252+
});
253+
254+
assertArrayEquals(BytesReference.toBytes(blobBytes), targetBytes);
255+
}
256+
257+
public void testMultipartCopy() {
258+
final var sourceBlobName = randomIdentifier();
259+
// executeMultipart requires a minimum part size of 5 MiB
260+
final var blobBytes = randomBytesReference(randomIntBetween(5 * 1024 * 1024, 10 * 1024 * 1024));
261+
final var destinationBlobName = randomIdentifier();
262+
263+
final var repository = getRepository();
264+
265+
final var targetBytes = executeOnBlobStore(repository, sourceBlobContainer -> {
266+
sourceBlobContainer.writeBlob(randomPurpose(), sourceBlobName, blobBytes, true);
267+
268+
final S3BlobContainer destinationBlobContainer = (S3BlobContainer) repository.blobStore()
269+
.blobContainer(repository.basePath().add("target"));
270+
destinationBlobContainer.executeMultipartCopy(
271+
randomPurpose(),
272+
(S3BlobContainer) sourceBlobContainer,
273+
sourceBlobName,
274+
destinationBlobName,
275+
blobBytes.length()
276+
);
277+
278+
return destinationBlobContainer.readBlob(randomPurpose(), destinationBlobName).readAllBytes();
279+
});
280+
281+
assertArrayEquals(BytesReference.toBytes(blobBytes), targetBytes);
282+
}
231283
}

0 commit comments

Comments
 (0)