Skip to content

Commit 4779e0c

Browse files
committed
Reverted changes to keyword field mapper
1 parent f117614 commit 4779e0c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,14 @@ private boolean indexValue(DocumentParserContext context, String value) {
12211221
return indexValue(context, new Text(value));
12221222
}
12231223

1224+
/**
1225+
* Returns whether this field should be stored separately as a {@link StoredField} for supporting synthetic source.
1226+
*/
1227+
private boolean storeIgnoredValuesForSyntheticSource() {
1228+
// skip all fields that are multi-fields
1229+
return fieldType().isSyntheticSourceEnabled && fieldType().isWithinMultiField == false;
1230+
}
1231+
12241232
private boolean indexValue(DocumentParserContext context, XContentString value) {
12251233
// nothing to index
12261234
if (value == null) {
@@ -1232,17 +1240,18 @@ private boolean indexValue(DocumentParserContext context, XContentString value)
12321240
return false;
12331241
}
12341242

1235-
// if the value's length exceeds ignore_above, then don't index it. Instead, store it in ignored source
1236-
// that being said, don't store multi fields in ignored source as thats the responsibility of the parent
1237-
if (value.stringLength() > fieldType().ignoreAbove() && isWithinMultiField == false) {
1243+
// if the value's length exceeds ignore_above, then don't index it
1244+
if (value.stringLength() > fieldType().ignoreAbove()) {
12381245
context.addIgnoredField(fullPath());
1239-
// unless synthetic source is enabled, then store a copy of the value so that synthetic source be load it
1240-
if (fieldType().isSyntheticSourceEnabled) {
1246+
1247+
// if synthetic source is enabled, then store a copy of the value so that synthetic source be load it
1248+
if (storeIgnoredValuesForSyntheticSource()) {
12411249
var utfBytes = value.bytes();
12421250
var bytesRef = new BytesRef(utfBytes.bytes(), utfBytes.offset(), utfBytes.length());
12431251
final String fieldName = fieldType().syntheticSourceFallbackFieldName();
12441252
context.doc().add(new StoredField(fieldName, bytesRef));
12451253
}
1254+
12461255
return false;
12471256
}
12481257

server/src/test/java/org/elasticsearch/index/mapper/TextFieldMapperTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public void testStoreParameterDefaults() throws IOException {
311311
}
312312
}
313313

314-
public void test_store_parameters_defaults_to_false_with_latest_index_version_when_synthetic_source_is_enabled() throws IOException {
314+
public void test_store_parameter_defaults_to_false_with_latest_index_version_when_synthetic_source_is_enabled() throws IOException {
315315
var indexSettings = getIndexSettingsBuilder().put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "synthetic").build();
316316

317317
var mapping = mapping(b -> {

0 commit comments

Comments
 (0)