Tidy up some noise during indexing with synthetic source. (#123724)

This commit is contained in:
Martijn van Groningen 2025-02-28 17:52:17 +01:00 committed by GitHub
parent e05304bc2d
commit 086329c5cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 4 deletions

View File

@ -157,6 +157,7 @@ public class MatchOnlyTextFieldMapper extends FieldMapper {
private final Analyzer indexAnalyzer;
private final TextFieldType textFieldType;
private final String originalName;
public MatchOnlyTextFieldType(
String name,
@ -168,6 +169,7 @@ public class MatchOnlyTextFieldMapper extends FieldMapper {
super(name, true, false, false, tsi, meta);
this.indexAnalyzer = Objects.requireNonNull(indexAnalyzer);
this.textFieldType = new TextFieldType(name, isSyntheticSource);
this.originalName = isSyntheticSource ? name() + "._original" : null;
}
public MatchOnlyTextFieldType(String name) {
@ -394,7 +396,7 @@ public class MatchOnlyTextFieldMapper extends FieldMapper {
}
private String storedFieldNameForSyntheticSource() {
return name() + "._original";
return originalName;
}
}

View File

@ -63,7 +63,8 @@ public class FieldArrayContext {
offsetToOrd[nullOffset] = -1;
}
try (var streamOutput = new BytesStreamOutput()) {
int expectedSize = offsetToOrd.length + 1; // Initialize buffer to avoid unnecessary resizing, assume 1 byte per offset + size.
try (var streamOutput = new BytesStreamOutput(expectedSize)) {
// Could just use vint for array length, but this allows for decoding my_field: null as -1
streamOutput.writeVInt(BitUtil.zigZagEncode(offsetToOrd.length));
for (int ord : offsetToOrd) {

View File

@ -1058,6 +1058,7 @@ public final class KeywordFieldMapper extends FieldMapper {
private final boolean useDocValuesSkipper;
private final String offsetsFieldName;
private final SourceKeepMode indexSourceKeepMode;
private final String originalName;
private KeywordFieldMapper(
String simpleName,
@ -1089,6 +1090,7 @@ public final class KeywordFieldMapper extends FieldMapper {
this.useDocValuesSkipper = useDocValuesSkipper;
this.offsetsFieldName = offsetsFieldName;
this.indexSourceKeepMode = indexSourceKeepMode;
this.originalName = isSyntheticSource ? fullPath() + "._original" : null;
}
@Override
@ -1255,7 +1257,7 @@ public final class KeywordFieldMapper extends FieldMapper {
* for synthetic source.
*/
private String originalName() {
return fullPath() + "._original";
return originalName;
}
@Override

View File

@ -896,6 +896,7 @@ public class WildcardFieldMapper extends FieldMapper {
private final int ignoreAbove;
private final int ignoreAboveDefault;
private final boolean storeIgnored;
private final String originalName;
private WildcardFieldMapper(
String simpleName,
@ -911,6 +912,7 @@ public class WildcardFieldMapper extends FieldMapper {
this.indexVersionCreated = indexVersionCreated;
this.ignoreAbove = builder.ignoreAbove.getValue();
this.ignoreAboveDefault = builder.ignoreAboveDefault;
this.originalName = storeIgnored ? fullPath() + "._original" : null;
}
@Override
@ -956,7 +958,7 @@ public class WildcardFieldMapper extends FieldMapper {
}
private String originalName() {
return fullPath() + "._original";
return originalName;
}
void createFields(String value, LuceneDocument parseDoc, List<IndexableField> fields) {