Skip to content

Commit acf0e4d

Browse files
authored
Use IndexType in TermBasedFieldType constructors (elastic#137906)
In preparation for doc-value skippers being enabled in some keyword field types, TermBasedFieldType should take IndexType directly in its constructor rather than booleans for indexed and docvalues.
1 parent 6439699 commit acf0e4d

File tree

27 files changed

+107
-95
lines changed

27 files changed

+107
-95
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
@@ -48,6 +48,7 @@
4848
import org.elasticsearch.index.mapper.CompositeSyntheticFieldLoader;
4949
import org.elasticsearch.index.mapper.DocumentParserContext;
5050
import org.elasticsearch.index.mapper.FieldMapper;
51+
import org.elasticsearch.index.mapper.IndexType;
5152
import org.elasticsearch.index.mapper.KeywordFieldMapper;
5253
import org.elasticsearch.index.mapper.MappedFieldType;
5354
import org.elasticsearch.index.mapper.MapperBuilderContext;
@@ -188,7 +189,7 @@ public MatchOnlyTextFieldType(
188189
boolean storedFieldInBinaryFormat,
189190
KeywordFieldMapper.KeywordFieldType syntheticSourceDelegate
190191
) {
191-
super(name, true, false, false, tsi, meta, isSyntheticSource, withinMultiField);
192+
super(name, IndexType.terms(true, false), false, tsi, meta, isSyntheticSource, withinMultiField);
192193
this.indexAnalyzer = Objects.requireNonNull(indexAnalyzer);
193194
this.textFieldType = new TextFieldType(name, isSyntheticSource, withinMultiField, syntheticSourceDelegate);
194195
this.storedFieldInBinaryFormat = storedFieldInBinaryFormat;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.elasticsearch.index.analysis.NamedAnalyzer;
4444
import org.elasticsearch.index.mapper.DocumentParserContext;
4545
import org.elasticsearch.index.mapper.FieldMapper;
46+
import org.elasticsearch.index.mapper.IndexType;
4647
import org.elasticsearch.index.mapper.Mapper;
4748
import org.elasticsearch.index.mapper.MapperBuilderContext;
4849
import org.elasticsearch.index.mapper.MapperParsingException;
@@ -306,9 +307,8 @@ static class SearchAsYouTypeFieldType extends StringFieldType {
306307
) {
307308
super(
308309
name,
309-
fieldType.indexOptions() != IndexOptions.NONE,
310+
IndexType.terms(fieldType.indexOptions() != IndexOptions.NONE, false),
310311
fieldType.stored(),
311-
false,
312312
new TextSearchInfo(fieldType, similarity, searchAnalyzer, searchQuoteAnalyzer),
313313
meta
314314
);
@@ -433,7 +433,7 @@ static final class PrefixFieldType extends StringFieldType {
433433
final String parentField;
434434

435435
PrefixFieldType(String parentField, TextSearchInfo textSearchInfo, int minChars, int maxChars) {
436-
super(parentField + PREFIX_FIELD_SUFFIX, true, false, false, textSearchInfo, Collections.emptyMap());
436+
super(parentField + PREFIX_FIELD_SUFFIX, IndexType.terms(true, false), false, textSearchInfo, Collections.emptyMap());
437437
this.minChars = minChars;
438438
this.maxChars = maxChars;
439439
this.parentField = parentField;
@@ -574,7 +574,7 @@ static class ShingleFieldType extends StringFieldType {
574574
PrefixFieldType prefixFieldType;
575575

576576
ShingleFieldType(String name, int shingleSize, TextSearchInfo textSearchInfo) {
577-
super(name, true, false, false, textSearchInfo, Collections.emptyMap());
577+
super(name, IndexType.terms(true, false), false, textSearchInfo, Collections.emptyMap());
578578
this.shingleSize = shingleSize;
579579
}
580580

modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
2323
import org.elasticsearch.index.mapper.DocumentParserContext;
2424
import org.elasticsearch.index.mapper.FieldMapper;
25+
import org.elasticsearch.index.mapper.IndexType;
2526
import org.elasticsearch.index.mapper.StringFieldType;
2627
import org.elasticsearch.index.mapper.TextSearchInfo;
2728
import org.elasticsearch.index.mapper.ValueFetcher;
@@ -44,7 +45,7 @@ public static final class ParentIdFieldType extends StringFieldType {
4445
private final boolean eagerGlobalOrdinals;
4546

4647
public ParentIdFieldType(String name, boolean eagerGlobalOrdinals) {
47-
super(name, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
48+
super(name, IndexType.terms(true, true), false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
4849
this.eagerGlobalOrdinals = eagerGlobalOrdinals;
4950
}
5051

modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
2626
import org.elasticsearch.index.mapper.DocumentParserContext;
2727
import org.elasticsearch.index.mapper.FieldMapper;
28+
import org.elasticsearch.index.mapper.IndexType;
2829
import org.elasticsearch.index.mapper.MappedFieldType;
2930
import org.elasticsearch.index.mapper.Mapper;
3031
import org.elasticsearch.index.mapper.MapperBuilderContext;
@@ -151,7 +152,7 @@ public static final class JoinFieldType extends StringFieldType {
151152
private final Joiner joiner;
152153

153154
private JoinFieldType(String name, Joiner joiner, Map<String, String> meta) {
154-
super(name, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
155+
super(name, IndexType.terms(true, true), false, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
155156
this.joiner = joiner;
156157
}
157158

plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/ICUCollationKeywordFieldMapper.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
3434
import org.elasticsearch.index.mapper.DocumentParserContext;
3535
import org.elasticsearch.index.mapper.FieldMapper;
36+
import org.elasticsearch.index.mapper.IndexType;
3637
import org.elasticsearch.index.mapper.MappedFieldType;
3738
import org.elasticsearch.index.mapper.MapperBuilderContext;
3839
import org.elasticsearch.index.mapper.SourceValueFetcher;
@@ -62,26 +63,25 @@ public static final class CollationFieldType extends StringFieldType {
6263

6364
public CollationFieldType(
6465
String name,
65-
boolean isSearchable,
66+
IndexType indexType,
6667
boolean isStored,
67-
boolean hasDocValues,
6868
Collator collator,
6969
String nullValue,
7070
int ignoreAbove,
7171
Map<String, String> meta
7272
) {
73-
super(name, isSearchable, isStored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
73+
super(name, indexType, isStored, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
7474
this.collator = collator;
7575
this.nullValue = nullValue;
7676
this.ignoreAbove = ignoreAbove;
7777
}
7878

7979
public CollationFieldType(String name, boolean searchable, Collator collator) {
80-
this(name, searchable, false, true, collator, null, Integer.MAX_VALUE, Collections.emptyMap());
80+
this(name, IndexType.terms(searchable, true), false, collator, null, Integer.MAX_VALUE, Collections.emptyMap());
8181
}
8282

8383
public CollationFieldType(String name, Collator collator) {
84-
this(name, true, false, true, collator, null, Integer.MAX_VALUE, Collections.emptyMap());
84+
this(name, IndexType.terms(true, true), false, collator, null, Integer.MAX_VALUE, Collections.emptyMap());
8585
}
8686

8787
@Override
@@ -327,9 +327,8 @@ public ICUCollationKeywordFieldMapper build(MapperBuilderContext context) {
327327
final Collator collator = params.buildCollator();
328328
CollationFieldType ft = new CollationFieldType(
329329
context.buildFullName(leafName()),
330-
indexed.getValue(),
330+
IndexType.terms(indexed.get(), hasDocValues.get()),
331331
stored.getValue(),
332-
hasDocValues.getValue(),
333332
collator,
334333
nullValue.getValue(),
335334
ignoreAbove.getValue(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public BooleanFieldType(
224224
boolean isDimension,
225225
boolean isSyntheticSource
226226
) {
227-
super(name, isIndexed, isStored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
227+
super(name, IndexType.terms(isIndexed, hasDocValues), isStored, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
228228
this.nullValue = nullValue;
229229
this.scriptValues = scriptValues;
230230
this.isDimension = isDimension;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,13 @@ public static final class CompletionFieldType extends TermBasedFieldType {
251251
private ContextMappings contextMappings = null;
252252

253253
public CompletionFieldType(String name, NamedAnalyzer searchAnalyzer, Map<String, String> meta) {
254-
super(name, true, false, false, new TextSearchInfo(Defaults.FIELD_TYPE, null, searchAnalyzer, searchAnalyzer), meta);
254+
super(
255+
name,
256+
IndexType.terms(true, false),
257+
false,
258+
new TextSearchInfo(Defaults.FIELD_TYPE, null, searchAnalyzer, searchAnalyzer),
259+
meta
260+
);
255261
}
256262

257263
public void setContextMappings(ContextMappings contextMappings) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static FieldNamesFieldType get(boolean enabled) {
120120
}
121121

122122
private FieldNamesFieldType(boolean enabled) {
123-
super(Defaults.NAME, true, false, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
123+
super(Defaults.NAME, IndexType.terms(true, false), false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
124124
this.enabled = enabled;
125125
}
126126

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static Field syntheticIdField(String id) {
8888
protected abstract static class AbstractIdFieldType extends TermBasedFieldType {
8989

9090
public AbstractIdFieldType() {
91-
super(NAME, true, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
91+
super(NAME, IndexType.terms(true, false), true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
9292
}
9393

9494
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private static MetadataFieldMapper getInstance(IndexVersion indexVersion) {
5757
public static final class LegacyIgnoredFieldType extends StringFieldType {
5858

5959
private LegacyIgnoredFieldType() {
60-
super(NAME, true, true, false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
60+
super(NAME, IndexType.terms(true, false), true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
6161
}
6262

6363
@Override
@@ -88,7 +88,7 @@ public Query existsQuery(SearchExecutionContext context) {
8888
public static final class IgnoredFieldType extends StringFieldType {
8989

9090
private IgnoredFieldType() {
91-
super(NAME, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
91+
super(NAME, IndexType.terms(true, true), false, TextSearchInfo.SIMPLE_MATCH_ONLY, Collections.emptyMap());
9292
}
9393

9494
@Override

0 commit comments

Comments
 (0)