Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public static class MatchOnlyTextFieldType extends StringFieldType {

private final Analyzer indexAnalyzer;
private final TextFieldType textFieldType;
private final String originalName;

public MatchOnlyTextFieldType(
String name,
Expand All @@ -168,6 +169,7 @@ public MatchOnlyTextFieldType(
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) {
Expand Down Expand Up @@ -394,7 +396,7 @@ protected BytesRef storedToBytesRef(Object stored) {
}

private String storedFieldNameForSyntheticSource() {
return name() + "._original";
return originalName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ void addToLuceneDocument(DocumentParserContext context) throws IOException {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ public boolean hasDocValuesSkipper() {
private final boolean useDocValuesSkipper;
private final String offsetsFieldName;
private final SourceKeepMode indexSourceKeepMode;
private final String originalName;

private KeywordFieldMapper(
String simpleName,
Expand Down Expand Up @@ -1089,6 +1090,7 @@ private KeywordFieldMapper(
this.useDocValuesSkipper = useDocValuesSkipper;
this.offsetsFieldName = offsetsFieldName;
this.indexSourceKeepMode = indexSourceKeepMode;
this.originalName = isSyntheticSource ? fullPath() + "._original" : null;
}

@Override
Expand Down Expand Up @@ -1255,7 +1257,7 @@ boolean hasNormalizer() {
* for synthetic source.
*/
private String originalName() {
return fullPath() + "._original";
return originalName;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ protected String parseSourceValue(Object value) {
private final int ignoreAbove;
private final int ignoreAboveDefault;
private final boolean storeIgnored;
private final String originalName;

private WildcardFieldMapper(
String simpleName,
Expand All @@ -911,6 +912,7 @@ private WildcardFieldMapper(
this.indexVersionCreated = indexVersionCreated;
this.ignoreAbove = builder.ignoreAbove.getValue();
this.ignoreAboveDefault = builder.ignoreAboveDefault;
this.originalName = storeIgnored ? fullPath() + "._original" : null;
}

@Override
Expand Down Expand Up @@ -956,7 +958,7 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
}

private String originalName() {
return fullPath() + "._original";
return originalName;
}

void createFields(String value, LuceneDocument parseDoc, List<IndexableField> fields) {
Expand Down