percolator: remove deprecated map_unmapped_fields_as_string setting
This commit is contained in:
parent
65157e9428
commit
ecb1d07d00
|
@ -32,6 +32,7 @@ Elasticsearch 6.x in order to be readable by Elasticsearch 7.x.
|
||||||
* <<breaking_70_analysis_changes>>
|
* <<breaking_70_analysis_changes>>
|
||||||
* <<breaking_70_api_changes>>
|
* <<breaking_70_api_changes>>
|
||||||
* <<breaking_70_java_changes>>
|
* <<breaking_70_java_changes>>
|
||||||
|
* <<breaking_70_settings_changes>>
|
||||||
|
|
||||||
|
|
||||||
include::migrate_7_0/aggregations.asciidoc[]
|
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/plugins.asciidoc[]
|
||||||
include::migrate_7_0/api.asciidoc[]
|
include::migrate_7_0/api.asciidoc[]
|
||||||
include::migrate_7_0/java.asciidoc[]
|
include::migrate_7_0/java.asciidoc[]
|
||||||
|
include::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.
|
|
@ -50,8 +50,6 @@ import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.collect.Tuple;
|
import org.elasticsearch.common.collect.Tuple;
|
||||||
import org.elasticsearch.common.hash.MurmurHash3;
|
import org.elasticsearch.common.hash.MurmurHash3;
|
||||||
import org.elasticsearch.common.io.stream.OutputStreamStreamOutput;
|
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.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -97,13 +95,9 @@ import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQuery
|
||||||
public class PercolatorFieldMapper extends FieldMapper {
|
public class PercolatorFieldMapper extends FieldMapper {
|
||||||
|
|
||||||
static final XContentType QUERY_BUILDER_CONTENT_TYPE = XContentType.SMILE;
|
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(
|
static final Setting<Boolean> INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING = Setting.boolSetting(
|
||||||
"index.percolator.map_unmapped_fields_as_text", false, Setting.Property.IndexScope);
|
"index.percolator.map_unmapped_fields_as_text", false, Setting.Property.IndexScope);
|
||||||
static final String CONTENT_TYPE = "percolator";
|
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();
|
private static final FieldType FIELD_TYPE = new FieldType();
|
||||||
|
|
||||||
static final byte FIELD_VALUE_SEPARATOR = 0; // nul code point
|
static final byte FIELD_VALUE_SEPARATOR = 0; // nul code point
|
||||||
|
@ -359,21 +353,8 @@ public class PercolatorFieldMapper extends FieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean getMapUnmappedFieldAsText(Settings indexSettings) {
|
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
|
@Override
|
||||||
public FieldMapper updateFieldType(Map<String, MappedFieldType> fullNameToFieldType) {
|
public FieldMapper updateFieldType(Map<String, MappedFieldType> fullNameToFieldType) {
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class PercolatorPlugin extends Plugin implements MapperPlugin, SearchPlug
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Setting<?>> getSettings() {
|
public List<Setting<?>> getSettings() {
|
||||||
return Arrays.asList(PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING,
|
return Arrays.asList(PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_TEXT_SETTING);
|
||||||
PercolatorFieldMapper.INDEX_MAP_UNMAPPED_FIELDS_AS_STRING_SETTING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.percolator;
|
||||||
import org.apache.lucene.search.join.ScoreMode;
|
import org.apache.lucene.search.join.ScoreMode;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.support.WriteRequest;
|
import org.elasticsearch.action.support.WriteRequest;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
@ -220,21 +219,4 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase {
|
||||||
assertSearchHits(response, "1");
|
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});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue