mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
Update multi field stored by default index version check (#129386)
Relates to #129126
This commit is contained in:
parent
3f9bf9a6b8
commit
a0cc698fa2
3 changed files with 13 additions and 3 deletions
|
@ -33,7 +33,6 @@ import org.elasticsearch.common.CheckedIntFunction;
|
|||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.index.IndexVersion;
|
||||
import org.elasticsearch.index.IndexVersions;
|
||||
import org.elasticsearch.index.analysis.IndexAnalyzers;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.fielddata.FieldDataContext;
|
||||
|
@ -71,6 +70,8 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.elasticsearch.index.mapper.TextFieldMapper.Builder.multiFieldsNotStoredByDefaultIndexVersionCheck;
|
||||
|
||||
/**
|
||||
* A {@link FieldMapper} for full-text fields that only indexes
|
||||
* {@link IndexOptions#DOCS} and runs positional queries by looking at the
|
||||
|
@ -140,7 +141,7 @@ public class MatchOnlyTextFieldMapper extends FieldMapper {
|
|||
public MatchOnlyTextFieldMapper build(MapperBuilderContext context) {
|
||||
MatchOnlyTextFieldType tft = buildFieldType(context);
|
||||
final boolean storeSource;
|
||||
if (indexCreatedVersion.onOrAfter(IndexVersions.MAPPER_TEXT_MATCH_ONLY_MULTI_FIELDS_DEFAULT_NOT_STORED)) {
|
||||
if (multiFieldsNotStoredByDefaultIndexVersionCheck(indexCreatedVersion)) {
|
||||
storeSource = context.isSourceSynthetic()
|
||||
&& withinMultiField == false
|
||||
&& multiFieldsBuilder.hasSyntheticSourceCompatibleKeywordField() == false;
|
||||
|
|
|
@ -142,6 +142,7 @@ public class IndexVersions {
|
|||
public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ_BACKPORT_8_X = def(8_530_0_00, Version.LUCENE_9_12_1);
|
||||
public static final IndexVersion SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X = def(8_531_0_00, Version.LUCENE_9_12_1);
|
||||
public static final IndexVersion INDEX_INT_SORT_INT_TYPE_8_19 = def(8_532_0_00, Version.LUCENE_9_12_1);
|
||||
public static final IndexVersion MAPPER_TEXT_MATCH_ONLY_MULTI_FIELDS_DEFAULT_NOT_STORED_8_19 = def(8_533_0_00, Version.LUCENE_9_12_1);
|
||||
public static final IndexVersion UPGRADE_TO_LUCENE_10_0_0 = def(9_000_0_00, Version.LUCENE_10_0_0);
|
||||
public static final IndexVersion LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT = def(9_001_0_00, Version.LUCENE_10_0_0);
|
||||
public static final IndexVersion TIME_BASED_K_ORDERED_DOC_ID = def(9_002_0_00, Version.LUCENE_10_0_0);
|
||||
|
|
|
@ -311,7 +311,7 @@ public final class TextFieldMapper extends FieldMapper {
|
|||
// Note that if current builder is a multi field, then we don't need to store, given that responsibility lies with parent field
|
||||
this.withinMultiField = withinMultiField;
|
||||
this.store = Parameter.storeParam(m -> ((TextFieldMapper) m).store, () -> {
|
||||
if (indexCreatedVersion.onOrAfter(IndexVersions.MAPPER_TEXT_MATCH_ONLY_MULTI_FIELDS_DEFAULT_NOT_STORED)) {
|
||||
if (multiFieldsNotStoredByDefaultIndexVersionCheck(indexCreatedVersion)) {
|
||||
return isSyntheticSourceEnabled
|
||||
&& this.withinMultiField == false
|
||||
&& multiFieldsBuilder.hasSyntheticSourceCompatibleKeywordField() == false;
|
||||
|
@ -329,6 +329,14 @@ public final class TextFieldMapper extends FieldMapper {
|
|||
this.isSyntheticSourceEnabled = isSyntheticSourceEnabled;
|
||||
}
|
||||
|
||||
public static boolean multiFieldsNotStoredByDefaultIndexVersionCheck(IndexVersion indexCreatedVersion) {
|
||||
return indexCreatedVersion.onOrAfter(IndexVersions.MAPPER_TEXT_MATCH_ONLY_MULTI_FIELDS_DEFAULT_NOT_STORED)
|
||||
|| indexCreatedVersion.between(
|
||||
IndexVersions.MAPPER_TEXT_MATCH_ONLY_MULTI_FIELDS_DEFAULT_NOT_STORED_8_19,
|
||||
IndexVersions.UPGRADE_TO_LUCENE_10_0_0
|
||||
);
|
||||
}
|
||||
|
||||
public Builder index(boolean index) {
|
||||
this.index.setValue(index);
|
||||
return this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue