From ecb1d07d00b57bb26792ea09a5e44c4acf0734a1 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 3 Jan 2018 12:16:42 +0100 Subject: [PATCH] percolator: remove deprecated map_unmapped_fields_as_string setting --- docs/reference/migration/migrate_7_0.asciidoc | 2 ++ .../migration/migrate_7_0/settings.asciidoc | 8 +++++++ .../percolator/PercolatorFieldMapper.java | 21 +------------------ .../percolator/PercolatorPlugin.java | 3 +-- .../PercolatorQuerySearchTests.java | 18 ---------------- 5 files changed, 12 insertions(+), 40 deletions(-) create mode 100644 docs/reference/migration/migrate_7_0/settings.asciidoc diff --git a/docs/reference/migration/migrate_7_0.asciidoc b/docs/reference/migration/migrate_7_0.asciidoc index 4fa1b5f0357..130f0ca80cc 100644 --- a/docs/reference/migration/migrate_7_0.asciidoc +++ b/docs/reference/migration/migrate_7_0.asciidoc @@ -32,6 +32,7 @@ Elasticsearch 6.x in order to be readable by Elasticsearch 7.x. * <> * <> * <> +* <> include::migrate_7_0/aggregations.asciidoc[] @@ -43,3 +44,4 @@ include::migrate_7_0/search.asciidoc[] include::migrate_7_0/plugins.asciidoc[] include::migrate_7_0/api.asciidoc[] include::migrate_7_0/java.asciidoc[] +include::migrate_7_0/settings.asciidoc[] diff --git a/docs/reference/migration/migrate_7_0/settings.asciidoc b/docs/reference/migration/migrate_7_0/settings.asciidoc new file mode 100644 index 00000000000..1035bc73393 --- /dev/null +++ b/docs/reference/migration/migrate_7_0/settings.asciidoc @@ -0,0 +1,8 @@ +[[breaking_70_settings_changes]] + +=== Settings changes + +==== Percolator + +* The deprecated `index.percolator.map_unmapped_fields_as_string` setting has been removed in favour of + the `index.percolator.map_unmapped_fields_as_text` setting. \ No newline at end of file diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java index e44a36cd267..986ccd809fd 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java @@ -50,8 +50,6 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.hash.MurmurHash3; import org.elasticsearch.common.io.stream.OutputStreamStreamOutput; -import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -97,13 +95,9 @@ import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQuery public class PercolatorFieldMapper extends FieldMapper { static final XContentType QUERY_BUILDER_CONTENT_TYPE = XContentType.SMILE; - @Deprecated - static final Setting INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING = Setting.boolSetting( - "index.percolator.map_unmapped_fields_as_string", false, Setting.Property.IndexScope, Setting.Property.Deprecated); static final Setting INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING = Setting.boolSetting( "index.percolator.map_unmapped_fields_as_text", false, Setting.Property.IndexScope); static final String CONTENT_TYPE = "percolator"; - private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(PercolatorFieldMapper.class)); private static final FieldType FIELD_TYPE = new FieldType(); static final byte FIELD_VALUE_SEPARATOR = 0; // nul code point @@ -359,20 +353,7 @@ public class PercolatorFieldMapper extends FieldMapper { } private static boolean getMapUnmappedFieldAsText(Settings indexSettings) { - if (INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING.exists(indexSettings) && - INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING.exists(indexSettings)) { - throw new IllegalArgumentException("Either specify [" + INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING.getKey() + - "] or [" + INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING.getKey() + "] setting, not both"); - } - - if (INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING.exists(indexSettings)) { - DEPRECATION_LOGGER.deprecatedAndMaybeLog(INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING.getKey(), - "The [" + INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING.getKey() + - "] setting is deprecated in favour for the [" + INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING.getKey() + "] setting"); - return INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING.get(indexSettings); - } else { - return INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING.get(indexSettings); - } + return INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING.get(indexSettings); } @Override diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java index 7128060448c..9c8b6e8c67f 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java @@ -57,8 +57,7 @@ public class PercolatorPlugin extends Plugin implements MapperPlugin, SearchPlug @Override public List> getSettings() { - return Arrays.asList(PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING, - PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING); + return Arrays.asList(PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING); } @Override diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java index 15a33f2090b..3d8f5b1deb5 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java @@ -21,7 +21,6 @@ package org.elasticsearch.percolator; import org.apache.lucene.search.join.ScoreMode; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -220,21 +219,4 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase { assertSearchHits(response, "1"); } - public void testMapUnmappedFieldAsString() throws IOException { - Settings.Builder settings = Settings.builder() - .put("index.percolator.map_unmapped_fields_as_string", true); - createIndex("test", settings.build(), "query", "query", "type=percolator"); - client().prepareIndex("test", "query", "1") - .setSource(jsonBuilder().startObject().field("query", matchQuery("field1", "value")).endObject()).get(); - client().admin().indices().prepareRefresh().get(); - - SearchResponse response = client().prepareSearch("test") - .setQuery(new PercolateQueryBuilder("query", jsonBuilder().startObject().field("field1", "value").endObject().bytes(), - XContentType.JSON)) - .get(); - assertHitCount(response, 1); - assertSearchHits(response, "1"); - assertSettingDeprecationsAndWarnings(new Setting[]{PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING}); - } - }