Skip to content

Commit 9e05896

Browse files
committed
Removed TextFamilyFieldType in favor of StringFieldType
1 parent a56c4bb commit 9e05896

File tree

6 files changed

+32
-36
lines changed

6 files changed

+32
-36
lines changed

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.elasticsearch.index.mapper.MapperBuilderContext;
5454
import org.elasticsearch.index.mapper.SourceLoader;
5555
import org.elasticsearch.index.mapper.SourceValueFetcher;
56+
import org.elasticsearch.index.mapper.StringFieldType;
5657
import org.elasticsearch.index.mapper.TextFamilyFieldMapper;
5758
import org.elasticsearch.index.mapper.TextFieldMapper;
5859
import org.elasticsearch.index.mapper.TextFieldMapper.TextFieldType;
@@ -189,7 +190,7 @@ private static boolean isSyntheticSourceStoredFieldInBinaryFormat(IndexVersion i
189190
)
190191
);
191192

192-
public static class MatchOnlyTextFieldType extends TextFamilyFieldType {
193+
public static class MatchOnlyTextFieldType extends StringFieldType {
193194

194195
private final Analyzer indexAnalyzer;
195196
private final TextFieldType textFieldType;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ private static boolean indexSortConfigByHostName(final IndexSortConfig indexSort
550550

551551
public static final TypeParser PARSER = createTypeParserWithLegacySupport(Builder::new);
552552

553-
public static final class KeywordFieldType extends TextFamilyFieldMapper.TextFamilyFieldType {
553+
public static final class KeywordFieldType extends StringFieldType {
554554

555555
private final int ignoreAbove;
556556
private final String nullValue;

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,34 @@ public abstract class StringFieldType extends TermBasedFieldType {
4343

4444
private static final Pattern WILDCARD_PATTERN = Pattern.compile("(\\\\.)|([?*]+)");
4545

46+
// using Boolean instead of boolean is deliberate as not all children of this class care about these two fields
47+
protected final Boolean isSyntheticSourceEnabled;
48+
protected final Boolean isWithinMultiField;
49+
4650
public StringFieldType(
4751
String name,
4852
boolean isIndexed,
4953
boolean isStored,
5054
boolean hasDocValues,
5155
TextSearchInfo textSearchInfo,
5256
Map<String, String> meta
57+
) {
58+
this(name, isIndexed, isStored, hasDocValues, textSearchInfo, meta, null, null);
59+
}
60+
61+
public StringFieldType(
62+
String name,
63+
boolean isIndexed,
64+
boolean isStored,
65+
boolean hasDocValues,
66+
TextSearchInfo textSearchInfo,
67+
Map<String, String> meta,
68+
Boolean isSyntheticSourceEnabled,
69+
Boolean isWithinMultiField
5370
) {
5471
super(name, isIndexed, isStored, hasDocValues, textSearchInfo, meta);
72+
this.isSyntheticSourceEnabled = isSyntheticSourceEnabled;
73+
this.isWithinMultiField = isWithinMultiField;
5574
}
5675

5776
@Override
@@ -224,4 +243,12 @@ public Query rangeQuery(
224243
includeUpper
225244
);
226245
}
246+
247+
/**
248+
* Returns the name of the "fallback" field that can be used for synthetic source when the "main" field was not
249+
* stored for whatever reason.
250+
*/
251+
public String syntheticSourceFallbackFieldName() {
252+
return isSyntheticSourceEnabled ? name() + "._original" : null;
253+
}
227254
}

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import org.elasticsearch.index.IndexVersion;
1313
import org.elasticsearch.index.IndexVersions;
1414

15-
import java.util.Map;
16-
1715
/**
1816
* This class is meant to contain common functionality that is needed by the Text family of field mappers. Namely
1917
* {@link TextFieldMapper} and anything strongly related to it.
@@ -58,34 +56,4 @@ private boolean multiFieldsNotStoredByDefaultIndexVersionCheck() {
5856
);
5957
}
6058

61-
public abstract static class TextFamilyFieldType extends StringFieldType {
62-
63-
protected final boolean isSyntheticSourceEnabled;
64-
protected final boolean isWithinMultiField;
65-
66-
public TextFamilyFieldType(
67-
String name,
68-
boolean isIndexed,
69-
boolean isStored,
70-
boolean hasDocValues,
71-
TextSearchInfo textSearchInfo,
72-
Map<String, String> meta,
73-
boolean isSyntheticSourceEnabled,
74-
boolean isWithinMultiField
75-
) {
76-
super(name, isIndexed, isStored, hasDocValues, textSearchInfo, meta);
77-
this.isSyntheticSourceEnabled = isSyntheticSourceEnabled;
78-
this.isWithinMultiField = isWithinMultiField;
79-
}
80-
81-
/**
82-
* Returns the name of the "fallback" field that can be used for synthetic source when the "main" field was not
83-
* stored for whatever reason.
84-
*/
85-
public String syntheticSourceFallbackFieldName() {
86-
return isSyntheticSourceEnabled ? name() + "._original" : null;
87-
}
88-
89-
}
90-
9159
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ private static final class SubFieldInfo {
646646

647647
}
648648

649-
public static class TextFieldType extends TextFamilyFieldType {
649+
public static class TextFieldType extends StringFieldType {
650650

651651
private boolean fielddata;
652652
private FielddataFrequencyFilter filter;

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/patternedtext/PatternedTextFieldType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public class PatternedTextFieldType extends StringFieldType {
7373
) {
7474
// Though this type is based on doc_values, hasDocValues is set to false as the patterned_text type is not aggregatable.
7575
// This does not stop its child .template type from being aggregatable.
76-
super(name, true, false, false, tsi, meta);
76+
super(name, true, false, false, tsi, meta, isSyntheticSource, isWithinMultiField);
7777
this.indexAnalyzer = Objects.requireNonNull(indexAnalyzer);
7878
this.textFieldType = new TextFieldMapper.TextFieldType(name, isSyntheticSource, isWithinMultiField);
7979
}

0 commit comments

Comments
 (0)