Skip to content

Commit b45071d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into entitlements/absolute-path-check
2 parents ee5f399 + 17ed014 commit b45071d

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

docs/changelog/123105.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 123105
2+
summary: fix stale data in synthetic source for string stored field
3+
area: Mapping
4+
type: bug
5+
issues:
6+
- 123110

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ tests:
342342
- class: org.elasticsearch.xpack.ilm.TimeSeriesDataStreamsIT
343343
method: testSearchableSnapshotAction
344344
issue: https://github.com/elastic/elasticsearch/issues/123214
345+
- class: org.elasticsearch.action.admin.indices.diskusage.IndexDiskUsageAnalyzerTests
346+
method: testCompletionField
347+
issue: https://github.com/elastic/elasticsearch/issues/123269
345348

346349
# Examples:
347350
#

rest-api-spec/src/main/resources/rest-api-spec/api/ml.start_trained_model_deployment.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"options": ["starting", "started", "fully_allocated"],
7676
"default": "started"
7777
}
78+
},
79+
"body":{
80+
"description": "The settings for the trained model deployment",
81+
"required": false
7882
}
7983
}
8084
}

server/src/main/java/org/elasticsearch/index/mapper/StringStoredFieldFieldLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public final void write(XContentBuilder b) throws IOException {
5454
case 1:
5555
b.field(simpleName);
5656
write(b, values.get(0));
57-
return;
57+
break;
5858
default:
5959
b.startArray(simpleName);
6060
for (Object value : values) {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.index.mapper;
11+
12+
import org.elasticsearch.common.Strings;
13+
import org.elasticsearch.test.ESTestCase;
14+
import org.elasticsearch.xcontent.XContentBuilder;
15+
import org.elasticsearch.xcontent.XContentType;
16+
17+
import java.io.IOException;
18+
import java.util.List;
19+
import java.util.Map;
20+
import java.util.stream.Collectors;
21+
22+
public class StringStoredFieldFieldLoaderTests extends ESTestCase {
23+
24+
public void testLoadStoredFieldAndReset() throws IOException {
25+
var sfl = new StringStoredFieldFieldLoader("foo", "foo") {
26+
@Override
27+
protected void write(XContentBuilder b, Object value) throws IOException {
28+
b.value((String) value);
29+
}
30+
};
31+
32+
var storedFieldLoaders = sfl.storedFieldLoaders().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
33+
storedFieldLoaders.get("foo").load(List.of("one"));
34+
35+
var result = XContentBuilder.builder(XContentType.JSON.xContent());
36+
result.startObject();
37+
sfl.write(result);
38+
result.endObject();
39+
40+
assertEquals("""
41+
{"foo":"one"}""", Strings.toString(result));
42+
43+
var empty = XContentBuilder.builder(XContentType.JSON.xContent());
44+
empty.startObject();
45+
// reset() should have been called after previous write
46+
sfl.write(empty);
47+
empty.endObject();
48+
49+
assertEquals("{}", Strings.toString(empty));
50+
}
51+
52+
}

0 commit comments

Comments
 (0)