diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java index 6865983e180..a08401005c1 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java @@ -41,6 +41,8 @@ import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; @@ -1256,6 +1258,8 @@ public class IndexMetaData implements Diffable, ToXContent { } } + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(ESLoggerFactory.getLogger(IndexMetaData.class)); + /** * Returns true iff the given settings indicate that the index * associated with these settings allocates it's shards on a shared @@ -1266,7 +1270,7 @@ public class IndexMetaData implements Diffable, ToXContent { public boolean isOnSharedFilesystem(Settings settings) { // don't use the setting directly, not to trigger verbose deprecation logging return settings.getAsBooleanLenientForPreEs6Indices( - this.indexCreatedVersion, SETTING_SHARED_FILESYSTEM, isIndexUsingShadowReplicas(settings)); + this.indexCreatedVersion, SETTING_SHARED_FILESYSTEM, isIndexUsingShadowReplicas(settings), deprecationLogger); } /** @@ -1280,7 +1284,7 @@ public class IndexMetaData implements Diffable, ToXContent { public boolean isIndexUsingShadowReplicas(Settings settings) { // don't use the setting directly, not to trigger verbose deprecation logging - return settings.getAsBooleanLenientForPreEs6Indices(this.indexCreatedVersion, SETTING_SHADOW_REPLICAS, false); + return settings.getAsBooleanLenientForPreEs6Indices(this.indexCreatedVersion, SETTING_SHADOW_REPLICAS, false, deprecationLogger); } /** diff --git a/core/src/main/java/org/elasticsearch/common/settings/Settings.java b/core/src/main/java/org/elasticsearch/common/settings/Settings.java index e588b28b635..516b5bab45d 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/core/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -76,7 +76,6 @@ import static org.elasticsearch.common.unit.TimeValue.parseTimeValue; * An immutable settings implementation. */ public final class Settings implements ToXContent { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(Loggers.getLogger(Settings.class)); public static final Settings EMPTY = new Builder().build(); private static final Pattern ARRAY_PATTERN = Pattern.compile("(.*)\\.\\d+$"); @@ -327,7 +326,11 @@ public final class Settings implements ToXContent { * @deprecated Only used to provide automatic upgrades for pre 6.0 indices. */ @Deprecated - public Boolean getAsBooleanLenientForPreEs6Indices(Version indexVersion, String setting, Boolean defaultValue) { + public Boolean getAsBooleanLenientForPreEs6Indices( + final Version indexVersion, + final String setting, + final Boolean defaultValue, + final DeprecationLogger deprecationLogger) { if (indexVersion.before(Version.V_6_0_0_alpha1_UNRELEASED)) { //Only emit a warning if the setting's value is not a proper boolean final String value = get(setting, "false"); diff --git a/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java b/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java index 927397725be..bd5b238f7c5 100644 --- a/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java +++ b/core/src/main/java/org/elasticsearch/gateway/PrimaryShardAllocator.java @@ -479,9 +479,9 @@ public abstract class PrimaryShardAllocator extends BaseGatewayShardAllocator { // don't use the setting directly, not to trigger verbose deprecation logging return (metaData.isOnSharedFilesystem(metaData.getSettings()) || metaData.isOnSharedFilesystem(this.settings)) && (metaData.getSettings().getAsBooleanLenientForPreEs6Indices( - metaData.getCreationVersion(), IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false) || + metaData.getCreationVersion(), IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false, deprecationLogger) || this.settings.getAsBooleanLenientForPreEs6Indices - (metaData.getCreationVersion(), IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false)); + (metaData.getCreationVersion(), IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false, deprecationLogger)); } protected abstract FetchResult fetchData(ShardRouting shard, RoutingAllocation allocation); diff --git a/core/src/main/java/org/elasticsearch/index/IndexSettings.java b/core/src/main/java/org/elasticsearch/index/IndexSettings.java index 260cb593a82..bc1472d7a3d 100644 --- a/core/src/main/java/org/elasticsearch/index/IndexSettings.java +++ b/core/src/main/java/org/elasticsearch/index/IndexSettings.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.index.MergePolicy; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.IndexScopedSettings; import org.elasticsearch.common.settings.Setting; diff --git a/core/src/main/java/org/elasticsearch/index/MergePolicyConfig.java b/core/src/main/java/org/elasticsearch/index/MergePolicyConfig.java index c2625f7615b..b3a0224f983 100644 --- a/core/src/main/java/org/elasticsearch/index/MergePolicyConfig.java +++ b/core/src/main/java/org/elasticsearch/index/MergePolicyConfig.java @@ -23,6 +23,7 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.index.MergePolicy; import org.apache.lucene.index.NoMergePolicy; import org.apache.lucene.index.TieredMergePolicy; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.unit.ByteSizeUnit; @@ -165,7 +166,7 @@ public final class MergePolicyConfig { double segmentsPerTier = indexSettings.getValue(INDEX_MERGE_POLICY_SEGMENTS_PER_TIER_SETTING); double reclaimDeletesWeight = indexSettings.getValue(INDEX_MERGE_POLICY_RECLAIM_DELETES_WEIGHT_SETTING); this.mergesEnabled = indexSettings.getSettings() - .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), INDEX_MERGE_ENABLED, true); + .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), INDEX_MERGE_ENABLED, true, new DeprecationLogger(logger)); if (mergesEnabled == false) { logger.warn("[{}] is set to false, this should only be used in tests and can cause serious problems in production environments", INDEX_MERGE_ENABLED); } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java index 1486382521a..5e53a86129a 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java @@ -38,7 +38,7 @@ public class ASCIIFoldingTokenFilterFactory extends AbstractTokenFilterFactory i public ASCIIFoldingTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); preserveOriginal = settings.getAsBooleanLenientForPreEs6Indices( - indexSettings.getIndexVersionCreated(), PRESERVE_ORIGINAL.getPreferredName(), DEFAULT_PRESERVE_ORIGINAL); + indexSettings.getIndexVersionCreated(), PRESERVE_ORIGINAL.getPreferredName(), DEFAULT_PRESERVE_ORIGINAL, deprecationLogger); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java b/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java index 170e35905d5..80129e621d3 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java @@ -56,6 +56,8 @@ import org.apache.lucene.analysis.tr.TurkishAnalyzer; import org.apache.lucene.util.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.FileSystemUtils; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -79,6 +81,8 @@ import static java.util.Collections.unmodifiableMap; public class Analysis { + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(ESLoggerFactory.getLogger(Analysis.class)); + public static Version parseAnalysisVersion(Settings indexSettings, Settings settings, Logger logger) { // check for explicit version on the specific analyzer component String sVersion = settings.get("version"); @@ -179,13 +183,14 @@ public class Analysis { } public static CharArraySet parseArticles(Environment env, org.elasticsearch.Version indexCreatedVersion, Settings settings) { - boolean articlesCase = settings.getAsBooleanLenientForPreEs6Indices(indexCreatedVersion, "articles_case", false); + boolean articlesCase = settings.getAsBooleanLenientForPreEs6Indices(indexCreatedVersion, "articles_case", false, deprecationLogger); return parseWords(env, settings, "articles", null, null, articlesCase); } public static CharArraySet parseStopWords(Environment env, org.elasticsearch.Version indexCreatedVersion, Settings settings, CharArraySet defaultStopWords) { - boolean stopwordsCase = settings.getAsBooleanLenientForPreEs6Indices(indexCreatedVersion, "stopwords_case", false); + boolean stopwordsCase = + settings.getAsBooleanLenientForPreEs6Indices(indexCreatedVersion, "stopwords_case", false, deprecationLogger); return parseStopWords(env, settings, defaultStopWords, stopwordsCase); } @@ -214,7 +219,8 @@ public class Analysis { if (wordList == null) { return null; } - boolean ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexCreatedVersion, settingsPrefix + "_case", false); + boolean ignoreCase = + settings.getAsBooleanLenientForPreEs6Indices(indexCreatedVersion, settingsPrefix + "_case", false, deprecationLogger); return new CharArraySet(wordList, ignoreCase); } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/CJKBigramFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/CJKBigramFilterFactory.java index efc5d328686..65fc98d304b 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/CJKBigramFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/CJKBigramFilterFactory.java @@ -50,7 +50,8 @@ public final class CJKBigramFilterFactory extends AbstractTokenFilterFactory { public CJKBigramFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); - outputUnigrams = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "output_unigrams", false); + outputUnigrams = settings.getAsBooleanLenientForPreEs6Indices( + indexSettings.getIndexVersionCreated(), "output_unigrams", false, deprecationLogger); final String[] asArray = settings.getAsArray("ignored_scripts"); Set scripts = new HashSet<>(Arrays.asList("han", "hiragana", "katakana", "hangul")); if (asArray != null) { diff --git a/core/src/main/java/org/elasticsearch/index/analysis/CommonGramsTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/CommonGramsTokenFilterFactory.java index 54ffdd1276d..b64eb917df8 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/CommonGramsTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/CommonGramsTokenFilterFactory.java @@ -37,8 +37,8 @@ public class CommonGramsTokenFilterFactory extends AbstractTokenFilterFactory { public CommonGramsTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); - this.ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case", false); - this.queryMode = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "query_mode", false); + this.ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case", false, deprecationLogger); + this.queryMode = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "query_mode", false, deprecationLogger); this.words = Analysis.parseCommonWords(env, settings, null, ignoreCase); if (this.words == null) { diff --git a/core/src/main/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactory.java index a1eb3cd3a12..d7ceee5cb95 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactory.java @@ -46,8 +46,9 @@ public class HunspellTokenFilterFactory extends AbstractTokenFilterFactory { throw new IllegalArgumentException(String.format(Locale.ROOT, "Unknown hunspell dictionary for locale [%s]", locale)); } - dedup = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "dedup", true); - longestOnly = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "longest_only", false); + dedup = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "dedup", true, deprecationLogger); + longestOnly = + settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "longest_only", false, deprecationLogger); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java index deafe0e93c5..9cb01e75e55 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/KeywordMarkerTokenFilterFactory.java @@ -35,7 +35,8 @@ public class KeywordMarkerTokenFilterFactory extends AbstractTokenFilterFactory public KeywordMarkerTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); - boolean ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case", false); + boolean ignoreCase = + settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case", false, deprecationLogger); Set rules = Analysis.getWordSet(env, indexSettings.getIndexVersionCreated(), settings, "keywords"); if (rules == null) { throw new IllegalArgumentException("keyword filter requires either `keywords` or `keywords_path` to be configured"); @@ -47,4 +48,5 @@ public class KeywordMarkerTokenFilterFactory extends AbstractTokenFilterFactory public TokenStream create(TokenStream tokenStream) { return new SetKeywordMarkerFilter(tokenStream, keywordLookup); } + } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactory.java index 0923e09addf..459f3b94229 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/LimitTokenCountFilterFactory.java @@ -37,7 +37,7 @@ public class LimitTokenCountFilterFactory extends AbstractTokenFilterFactory { super(indexSettings, name, settings); this.maxTokenCount = settings.getAsInt("max_token_count", DEFAULT_MAX_TOKEN_COUNT); this.consumeAllTokens = settings.getAsBooleanLenientForPreEs6Indices( - indexSettings.getIndexVersionCreated(), "consume_all_tokens", DEFAULT_CONSUME_ALL_TOKENS); + indexSettings.getIndexVersionCreated(), "consume_all_tokens", DEFAULT_CONSUME_ALL_TOKENS, deprecationLogger); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java index 0b78620cdb3..d674143d308 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/PathHierarchyTokenizerFactory.java @@ -56,7 +56,8 @@ public class PathHierarchyTokenizerFactory extends AbstractTokenizerFactory { this.replacement = replacement.charAt(0); } this.skip = settings.getAsInt("skip", PathHierarchyTokenizer.DEFAULT_SKIP); - this.reverse = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "reverse", false); + this.reverse = + settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "reverse", false, deprecationLogger); } @Override @@ -66,4 +67,5 @@ public class PathHierarchyTokenizerFactory extends AbstractTokenizerFactory { } return new PathHierarchyTokenizer(bufferSize, delimiter, replacement, skip); } + } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java index a1ef58bcf38..a901ad4f1ad 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/PatternAnalyzerProvider.java @@ -36,7 +36,8 @@ public class PatternAnalyzerProvider extends AbstractIndexAnalyzerProvider tokenizerFactoryFactory = diff --git a/core/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java index 584e8401ad1..8606a60292c 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/UniqueTokenFilterFactory.java @@ -32,7 +32,7 @@ public class UniqueTokenFilterFactory extends AbstractTokenFilterFactory { public UniqueTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.onlyOnSamePosition = settings.getAsBooleanLenientForPreEs6Indices( - indexSettings.getIndexVersionCreated(), "only_on_same_position", false); + indexSettings.getIndexVersionCreated(), "only_on_same_position", false, deprecationLogger); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java index 44084344e4f..387c2c9e7f1 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/WordDelimiterTokenFilterFactory.java @@ -101,7 +101,7 @@ public class WordDelimiterTokenFilterFactory extends AbstractTokenFilterFactory } public int getFlag(int flag, Settings settings, String key, boolean defaultValue) { - if (settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), key, defaultValue)) { + if (settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), key, defaultValue, deprecationLogger)) { return flag; } return 0; diff --git a/core/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java index 9be3f38b02f..91c984c7a6b 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/compound/AbstractCompoundWordTokenFilterFactory.java @@ -45,7 +45,7 @@ public abstract class AbstractCompoundWordTokenFilterFactory extends AbstractTok minSubwordSize = settings.getAsInt("min_subword_size", CompoundWordTokenFilterBase.DEFAULT_MIN_SUBWORD_SIZE); maxSubwordSize = settings.getAsInt("max_subword_size", CompoundWordTokenFilterBase.DEFAULT_MAX_SUBWORD_SIZE); onlyLongestMatch = settings - .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "only_longest_match", false); + .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "only_longest_match", false, deprecationLogger); wordList = Analysis.getWordSet(env, indexSettings.getIndexVersionCreated(), settings, "word_list"); if (wordList == null) { throw new IllegalArgumentException("word_list must be provided for [" + name + "], either as a path to a file, or directly"); diff --git a/core/src/main/java/org/elasticsearch/index/similarity/BM25SimilarityProvider.java b/core/src/main/java/org/elasticsearch/index/similarity/BM25SimilarityProvider.java index 78c9a4b000c..a1323a95984 100644 --- a/core/src/main/java/org/elasticsearch/index/similarity/BM25SimilarityProvider.java +++ b/core/src/main/java/org/elasticsearch/index/similarity/BM25SimilarityProvider.java @@ -22,6 +22,8 @@ package org.elasticsearch.index.similarity; import org.apache.lucene.search.similarities.BM25Similarity; import org.apache.lucene.search.similarities.Similarity; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.Settings; /** @@ -43,8 +45,9 @@ public class BM25SimilarityProvider extends AbstractSimilarityProvider { super(name); float k1 = settings.getAsFloat("k1", 1.2f); float b = settings.getAsFloat("b", 0.75f); - boolean discountOverlaps = settings.getAsBooleanLenientForPreEs6Indices( - Version.indexCreated(indexSettings), "discount_overlaps", true); + final DeprecationLogger deprecationLogger = new DeprecationLogger(ESLoggerFactory.getLogger(getClass())); + boolean discountOverlaps = + settings.getAsBooleanLenientForPreEs6Indices(Version.indexCreated(indexSettings), "discount_overlaps", true, deprecationLogger); this.similarity = new BM25Similarity(k1, b); this.similarity.setDiscountOverlaps(discountOverlaps); @@ -57,4 +60,5 @@ public class BM25SimilarityProvider extends AbstractSimilarityProvider { public Similarity get() { return similarity; } + } diff --git a/core/src/main/java/org/elasticsearch/index/similarity/ClassicSimilarityProvider.java b/core/src/main/java/org/elasticsearch/index/similarity/ClassicSimilarityProvider.java index 79e73eaf7e7..e031c5b3dac 100644 --- a/core/src/main/java/org/elasticsearch/index/similarity/ClassicSimilarityProvider.java +++ b/core/src/main/java/org/elasticsearch/index/similarity/ClassicSimilarityProvider.java @@ -21,6 +21,8 @@ package org.elasticsearch.index.similarity; import org.apache.lucene.search.similarities.ClassicSimilarity; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.Settings; /** @@ -39,7 +41,7 @@ public class ClassicSimilarityProvider extends AbstractSimilarityProvider { public ClassicSimilarityProvider(String name, Settings settings, Settings indexSettings) { super(name); boolean discountOverlaps = settings.getAsBooleanLenientForPreEs6Indices( - Version.indexCreated(indexSettings), "discount_overlaps", true); + Version.indexCreated(indexSettings), "discount_overlaps", true, new DeprecationLogger(ESLoggerFactory.getLogger(getClass()))); this.similarity.setDiscountOverlaps(discountOverlaps); } @@ -50,4 +52,5 @@ public class ClassicSimilarityProvider extends AbstractSimilarityProvider { public ClassicSimilarity get() { return similarity; } + } diff --git a/core/src/main/java/org/elasticsearch/index/similarity/DFISimilarityProvider.java b/core/src/main/java/org/elasticsearch/index/similarity/DFISimilarityProvider.java index e795c7e232f..b1148fbb2d5 100644 --- a/core/src/main/java/org/elasticsearch/index/similarity/DFISimilarityProvider.java +++ b/core/src/main/java/org/elasticsearch/index/similarity/DFISimilarityProvider.java @@ -26,6 +26,8 @@ import org.apache.lucene.search.similarities.IndependenceSaturated; import org.apache.lucene.search.similarities.IndependenceStandardized; import org.apache.lucene.search.similarities.Similarity; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.Settings; import java.util.HashMap; @@ -59,7 +61,7 @@ public class DFISimilarityProvider extends AbstractSimilarityProvider { public DFISimilarityProvider(String name, Settings settings, Settings indexSettings) { super(name); boolean discountOverlaps = settings.getAsBooleanLenientForPreEs6Indices( - Version.indexCreated(indexSettings), "discount_overlaps", true); + Version.indexCreated(indexSettings), "discount_overlaps", true, new DeprecationLogger(ESLoggerFactory.getLogger(getClass()))); Independence measure = parseIndependence(settings); this.similarity = new DFISimilarity(measure); this.similarity.setDiscountOverlaps(discountOverlaps); diff --git a/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java b/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java index 4b1aa077b67..e1a2b940079 100644 --- a/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java +++ b/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java @@ -21,6 +21,8 @@ package org.elasticsearch.common.settings; import org.elasticsearch.Version; import org.elasticsearch.common.Booleans; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.loader.YamlSettingsLoader; import org.elasticsearch.test.ESTestCase; import org.hamcrest.Matchers; @@ -163,9 +165,11 @@ public class SettingsTests extends ESTestCase { .put("foo", falsy) .put("bar", truthy).build(); - assertFalse(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "foo", null)); - assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "bar", null)); - assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "baz", true)); + final DeprecationLogger deprecationLogger = new DeprecationLogger(ESLoggerFactory.getLogger("testLenientBooleanForPreEs6Index")); + + assertFalse(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "foo", null, deprecationLogger)); + assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "bar", null, deprecationLogger)); + assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "baz", true, deprecationLogger)); List expectedDeprecationWarnings = new ArrayList<>(); if (Booleans.isBoolean(falsy) == false) { @@ -191,10 +195,12 @@ public class SettingsTests extends ESTestCase { .put("foo", falsy) .put("bar", truthy).build(); + final DeprecationLogger deprecationLogger = + new DeprecationLogger(ESLoggerFactory.getLogger("testInvalidLenientBooleanForCurrentIndexVersion")); expectThrows(IllegalArgumentException.class, - () -> settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "foo", null)); + () -> settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "foo", null, deprecationLogger)); expectThrows(IllegalArgumentException.class, - () -> settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "bar", null)); + () -> settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "bar", null, deprecationLogger)); } @SuppressWarnings("deprecation") //#getAsBooleanLenientForPreEs6Indices is the test subject @@ -203,9 +209,11 @@ public class SettingsTests extends ESTestCase { .put("foo", "false") .put("bar", "true").build(); - assertFalse(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "foo", null)); - assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "bar", null)); - assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "baz", true)); + final DeprecationLogger deprecationLogger = + new DeprecationLogger(ESLoggerFactory.getLogger("testValidLenientBooleanForCurrentIndexVersion")); + assertFalse(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "foo", null, deprecationLogger)); + assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "bar", null, deprecationLogger)); + assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "baz", true, deprecationLogger)); } public void testMultLevelGetPrefix() { diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java index 25ac75812e8..7710c2e6715 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java @@ -131,7 +131,7 @@ public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory { } } - Boolean caseLevel = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "caseLevel", null); + Boolean caseLevel = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "caseLevel", null, deprecationLogger); if (caseLevel != null) { rbc.setCaseLevel(caseLevel); } @@ -147,7 +147,7 @@ public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory { } } - Boolean numeric = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "numeric", null); + Boolean numeric = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "numeric", null, deprecationLogger); if (numeric != null) { rbc.setNumericCollation(numeric); } @@ -158,7 +158,7 @@ public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory { } Boolean hiraganaQuaternaryMode = settings - .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "hiraganaQuaternaryMode", null); + .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "hiraganaQuaternaryMode", null, deprecationLogger); if (hiraganaQuaternaryMode != null) { rbc.setHiraganaQuaternary(hiraganaQuaternaryMode); } diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java index 57d6c70846f..712ad0add15 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java @@ -45,9 +45,9 @@ public class JapaneseStopTokenFilterFactory extends AbstractTokenFilterFactory{ public JapaneseStopTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); - this.ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case", false); + this.ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case", false, deprecationLogger); this.removeTrailing = settings - .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "remove_trailing", true); + .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "remove_trailing", true, deprecationLogger); this.stopWords = Analysis.parseWords(env, settings, "stopwords", JapaneseAnalyzer.getDefaultStopSet(), NAMED_STOP_WORDS, ignoreCase); } diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java index 21387f1982d..5bdafbe39e4 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java @@ -34,9 +34,9 @@ public class KuromojiIterationMarkCharFilterFactory extends AbstractCharFilterFa public KuromojiIterationMarkCharFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name); normalizeKanji = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "normalize_kanji", - JapaneseIterationMarkCharFilter.NORMALIZE_KANJI_DEFAULT); + JapaneseIterationMarkCharFilter.NORMALIZE_KANJI_DEFAULT, deprecationLogger); normalizeKana = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "normalize_kana", - JapaneseIterationMarkCharFilter.NORMALIZE_KANA_DEFAULT); + JapaneseIterationMarkCharFilter.NORMALIZE_KANA_DEFAULT, deprecationLogger); } @Override diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java index ae9247db9c6..4b85368da93 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java @@ -31,7 +31,8 @@ public class KuromojiReadingFormFilterFactory extends AbstractTokenFilterFactory public KuromojiReadingFormFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); - useRomaji = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "use_romaji", false); + useRomaji = + settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "use_romaji", false, deprecationLogger); } @Override diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java index 39dfc4ccc07..69da3bd2bc4 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java @@ -49,7 +49,7 @@ public class KuromojiTokenizerFactory extends AbstractTokenizerFactory { mode = getMode(settings); userDictionary = getUserDictionary(env, settings); discartPunctuation = settings - .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "discard_punctuation", true); + .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "discard_punctuation", true, deprecationLogger); nBestCost = settings.getAsInt(NBEST_COST, -1); nBestExamples = settings.get(NBEST_EXAMPLES); } diff --git a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java index 93f68000ad2..5c9a6a463d3 100644 --- a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java +++ b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java @@ -60,7 +60,7 @@ public class PhoneticTokenFilterFactory extends AbstractTokenFilterFactory { this.nametype = null; this.ruletype = null; this.maxcodelength = 0; - this.replace = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "replace", true); + this.replace = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "replace", true, deprecationLogger); // weird, encoder is null at last step in SimplePhoneticAnalysisTests, so we set it to metaphone as default String encodername = settings.get("encoder", "metaphone"); if ("metaphone".equalsIgnoreCase(encodername)) {