diff --git a/docs/reference/migration/migrate_8_0/search.asciidoc b/docs/reference/migration/migrate_8_0/search.asciidoc index b0c6c11f9e510..c36a027370a3b 100644 --- a/docs/reference/migration/migrate_8_0/search.asciidoc +++ b/docs/reference/migration/migrate_8_0/search.asciidoc @@ -57,3 +57,10 @@ deprecated in 7.6, and are now removed in 8.x. The form The `indices_boost` option in the search request used to accept the boosts both as an object and as an array. The object format has been deprecated since 5.2 and is now removed in 8.0. + +[float] +==== Removal of `use_field_mapping` for docvalues fields +In 7.0, we began formatting `docvalue_fields` by default using each field's +mapping definition. To ease the transition from 6.x, we added the format +option `use_field_mapping`. This parameter was deprecated in 7.0, and is now +removed in 8.0. diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java index 3d734e2471986..d204698f58ae4 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java @@ -18,16 +18,14 @@ */ package org.elasticsearch.search.fetch.subphase; -import org.apache.logging.log4j.LogManager; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.index.SortedNumericDocValues; import org.elasticsearch.common.document.DocumentField; -import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.index.fielddata.LeafFieldData; -import org.elasticsearch.index.fielddata.LeafNumericFieldData; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData; +import org.elasticsearch.index.fielddata.LeafFieldData; +import org.elasticsearch.index.fielddata.LeafNumericFieldData; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData; @@ -45,7 +43,6 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; -import java.util.Objects; import static org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType; import static org.elasticsearch.search.DocValueFormat.withNanosecondResolution; @@ -57,10 +54,6 @@ */ public final class FetchDocValuesPhase implements FetchSubPhase { - private static final String USE_DEFAULT_FORMAT = "use_field_mapping"; - private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger( - LogManager.getLogger(FetchDocValuesPhase.class)); - @Override public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOException { @@ -82,16 +75,6 @@ public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOExcept hits = hits.clone(); // don't modify the incoming hits Arrays.sort(hits, Comparator.comparingInt(SearchHit::docId)); - if (context.docValuesContext().fields().stream() - .map(f -> f.format) - .filter(USE_DEFAULT_FORMAT::equals) - .findAny() - .isPresent()) { - DEPRECATION_LOGGER.deprecatedAndMaybeLog("explicit_default_format", - "[" + USE_DEFAULT_FORMAT + "] is a special format that was only used to " + - "ease the transition to 7.x. It has become the default and shouldn't be set explicitly anymore."); - } - for (FieldAndFormat fieldAndFormat : context.docValuesContext().fields()) { String field = fieldAndFormat.field; MappedFieldType fieldType = context.mapperService().fieldType(field); @@ -105,10 +88,6 @@ public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOExcept } final DocValueFormat format; String formatDesc = fieldAndFormat.format; - if (Objects.equals(formatDesc, USE_DEFAULT_FORMAT)) { - // TODO: Remove in 8.x - formatDesc = null; - } if (isNanosecond) { format = withNanosecondResolution(fieldType.docValueFormat(formatDesc, null)); } else { diff --git a/server/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java b/server/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java index b3adac86591d3..ce5cdad36ee1c 100644 --- a/server/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java +++ b/server/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java @@ -889,42 +889,6 @@ public void testDocValueFields() throws Exception { assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValue(), equalTo("KmQ")); assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValue(), equalTo("::1")); - builder = client().prepareSearch().setQuery(matchAllQuery()) - .addDocValueField("text_field", "use_field_mapping") - .addDocValueField("keyword_field", "use_field_mapping") - .addDocValueField("byte_field", "use_field_mapping") - .addDocValueField("short_field", "use_field_mapping") - .addDocValueField("integer_field", "use_field_mapping") - .addDocValueField("long_field", "use_field_mapping") - .addDocValueField("float_field", "use_field_mapping") - .addDocValueField("double_field", "use_field_mapping") - .addDocValueField("date_field", "use_field_mapping") - .addDocValueField("boolean_field", "use_field_mapping") - .addDocValueField("binary_field", "use_field_mapping") - .addDocValueField("ip_field", "use_field_mapping"); - searchResponse = builder.get(); - - assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L)); - assertThat(searchResponse.getHits().getHits().length, equalTo(1)); - fields = new HashSet<>(searchResponse.getHits().getAt(0).getFields().keySet()); - assertThat(fields, equalTo(newHashSet("byte_field", "short_field", "integer_field", "long_field", - "float_field", "double_field", "date_field", "boolean_field", "text_field", "keyword_field", - "binary_field", "ip_field"))); - - assertThat(searchResponse.getHits().getAt(0).getFields().get("byte_field").getValue().toString(), equalTo("1")); - assertThat(searchResponse.getHits().getAt(0).getFields().get("short_field").getValue().toString(), equalTo("2")); - assertThat(searchResponse.getHits().getAt(0).getFields().get("integer_field").getValue(), equalTo((Object) 3L)); - assertThat(searchResponse.getHits().getAt(0).getFields().get("long_field").getValue(), equalTo((Object) 4L)); - assertThat(searchResponse.getHits().getAt(0).getFields().get("float_field").getValue(), equalTo((Object) 5.0)); - assertThat(searchResponse.getHits().getAt(0).getFields().get("double_field").getValue(), equalTo((Object) 6.0d)); - assertThat(searchResponse.getHits().getAt(0).getFields().get("date_field").getValue(), - equalTo(DateFormatter.forPattern("dateOptionalTime").format(date))); - assertThat(searchResponse.getHits().getAt(0).getFields().get("boolean_field").getValue(), equalTo((Object) true)); - assertThat(searchResponse.getHits().getAt(0).getFields().get("text_field").getValue(), equalTo("foo")); - assertThat(searchResponse.getHits().getAt(0).getFields().get("keyword_field").getValue(), equalTo("foo")); - assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValue(), equalTo("KmQ")); - assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValue(), equalTo("::1")); - builder = client().prepareSearch().setQuery(matchAllQuery()) .addDocValueField("byte_field", "#.0") .addDocValueField("short_field", "#.0") @@ -1029,7 +993,7 @@ public void testDocValueFieldsWithFieldAlias() throws Exception { SearchRequestBuilder builder = client().prepareSearch().setQuery(matchAllQuery()) .addDocValueField("text_field_alias") - .addDocValueField("date_field_alias", "use_field_mapping") + .addDocValueField("date_field_alias") .addDocValueField("date_field"); SearchResponse searchResponse = builder.get(); @@ -1091,7 +1055,7 @@ public void testWildcardDocValueFieldsWithFieldAlias() throws Exception { refresh("test"); SearchRequestBuilder builder = client().prepareSearch().setQuery(matchAllQuery()) - .addDocValueField("*alias", "use_field_mapping") + .addDocValueField("*alias") .addDocValueField("date_field"); SearchResponse searchResponse = builder.get();