Skip to content

Commit

Permalink
percolator: remove deprecated map_unmapped_fields_as_string setting
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvg committed Feb 1, 2018
1 parent 65157e9 commit ecb1d07
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 40 deletions.
2 changes: 2 additions & 0 deletions docs/reference/migration/migrate_7_0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Elasticsearch 6.x in order to be readable by Elasticsearch 7.x.
* <<breaking_70_analysis_changes>>
* <<breaking_70_api_changes>>
* <<breaking_70_java_changes>>
* <<breaking_70_settings_changes>>


include::migrate_7_0/aggregations.asciidoc[]
Expand All @@ -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[]
8 changes: 8 additions & 0 deletions docs/reference/migration/migrate_7_0/settings.asciidoc
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
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;
Expand Down Expand Up @@ -97,13 +95,9 @@
public class PercolatorFieldMapper extends FieldMapper {

static final XContentType QUERY_BUILDER_CONTENT_TYPE = XContentType.SMILE;
@Deprecated
static final Setting<Boolean> 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<Boolean> 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
Expand Down Expand Up @@ -359,20 +353,7 @@ Tuple<List<BytesRef>, Map<String, List<byte[]>>> extractTermsAndRanges(IndexRead
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public List<FetchSubPhase> getFetchSubPhases(FetchPhaseConstructionContext conte

@Override
public List<Setting<?>> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;
Expand Down Expand Up @@ -220,21 +219,4 @@ public void testMapUnmappedFieldAsText() throws IOException {
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});
}

}

0 comments on commit ecb1d07

Please sign in to comment.