Skip to content

Commit 724e24d

Browse files
authored
Remove use_field_mapping format option for docvalue fields. (#55622)
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 we can remove it in 8.0.
1 parent d67a1b4 commit 724e24d

File tree

3 files changed

+11
-61
lines changed

3 files changed

+11
-61
lines changed

docs/reference/migration/migrate_8_0/search.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ deprecated in 7.6, and are now removed in 8.x. The form
6363
The `indices_boost` option in the search request used to accept the boosts
6464
both as an object and as an array. The object format has been deprecated since
6565
5.2 and is now removed in 8.0.
66+
67+
[float]
68+
==== Removal of `use_field_mapping` for docvalues fields
69+
In 7.0, we began formatting `docvalue_fields` by default using each field's
70+
mapping definition. To ease the transition from 6.x, we added the format
71+
option `use_field_mapping`. This parameter was deprecated in 7.0, and is now
72+
removed in 8.0.

server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
*/
1919
package org.elasticsearch.search.fetch.subphase;
2020

21-
import org.apache.logging.log4j.LogManager;
2221
import org.apache.lucene.index.LeafReaderContext;
2322
import org.apache.lucene.index.ReaderUtil;
2423
import org.apache.lucene.index.SortedNumericDocValues;
2524
import org.elasticsearch.common.document.DocumentField;
26-
import org.elasticsearch.common.logging.DeprecationLogger;
27-
import org.elasticsearch.index.fielddata.LeafFieldData;
28-
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
2925
import org.elasticsearch.index.fielddata.IndexFieldData;
3026
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
27+
import org.elasticsearch.index.fielddata.LeafFieldData;
28+
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
3129
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
3230
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
3331
import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData;
@@ -45,7 +43,6 @@
4543
import java.util.Comparator;
4644
import java.util.HashMap;
4745
import java.util.List;
48-
import java.util.Objects;
4946

5047
import static org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
5148
import static org.elasticsearch.search.DocValueFormat.withNanosecondResolution;
@@ -57,10 +54,6 @@
5754
*/
5855
public final class FetchDocValuesPhase implements FetchSubPhase {
5956

60-
private static final String USE_DEFAULT_FORMAT = "use_field_mapping";
61-
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(
62-
LogManager.getLogger(FetchDocValuesPhase.class));
63-
6457
@Override
6558
public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOException {
6659

@@ -82,16 +75,6 @@ public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOExcept
8275
hits = hits.clone(); // don't modify the incoming hits
8376
Arrays.sort(hits, Comparator.comparingInt(SearchHit::docId));
8477

85-
if (context.docValuesContext().fields().stream()
86-
.map(f -> f.format)
87-
.filter(USE_DEFAULT_FORMAT::equals)
88-
.findAny()
89-
.isPresent()) {
90-
DEPRECATION_LOGGER.deprecatedAndMaybeLog("explicit_default_format",
91-
"[" + USE_DEFAULT_FORMAT + "] is a special format that was only used to " +
92-
"ease the transition to 7.x. It has become the default and shouldn't be set explicitly anymore.");
93-
}
94-
9578
for (FieldAndFormat fieldAndFormat : context.docValuesContext().fields()) {
9679
String field = fieldAndFormat.field;
9780
MappedFieldType fieldType = context.mapperService().fieldType(field);
@@ -105,10 +88,6 @@ public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOExcept
10588
}
10689
final DocValueFormat format;
10790
String formatDesc = fieldAndFormat.format;
108-
if (Objects.equals(formatDesc, USE_DEFAULT_FORMAT)) {
109-
// TODO: Remove in 8.x
110-
formatDesc = null;
111-
}
11291
if (isNanosecond) {
11392
format = withNanosecondResolution(fieldType.docValueFormat(formatDesc, null));
11493
} else {

server/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -889,42 +889,6 @@ public void testDocValueFields() throws Exception {
889889
assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValue(), equalTo("KmQ"));
890890
assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValue(), equalTo("::1"));
891891

892-
builder = client().prepareSearch().setQuery(matchAllQuery())
893-
.addDocValueField("text_field", "use_field_mapping")
894-
.addDocValueField("keyword_field", "use_field_mapping")
895-
.addDocValueField("byte_field", "use_field_mapping")
896-
.addDocValueField("short_field", "use_field_mapping")
897-
.addDocValueField("integer_field", "use_field_mapping")
898-
.addDocValueField("long_field", "use_field_mapping")
899-
.addDocValueField("float_field", "use_field_mapping")
900-
.addDocValueField("double_field", "use_field_mapping")
901-
.addDocValueField("date_field", "use_field_mapping")
902-
.addDocValueField("boolean_field", "use_field_mapping")
903-
.addDocValueField("binary_field", "use_field_mapping")
904-
.addDocValueField("ip_field", "use_field_mapping");
905-
searchResponse = builder.get();
906-
907-
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
908-
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
909-
fields = new HashSet<>(searchResponse.getHits().getAt(0).getFields().keySet());
910-
assertThat(fields, equalTo(newHashSet("byte_field", "short_field", "integer_field", "long_field",
911-
"float_field", "double_field", "date_field", "boolean_field", "text_field", "keyword_field",
912-
"binary_field", "ip_field")));
913-
914-
assertThat(searchResponse.getHits().getAt(0).getFields().get("byte_field").getValue().toString(), equalTo("1"));
915-
assertThat(searchResponse.getHits().getAt(0).getFields().get("short_field").getValue().toString(), equalTo("2"));
916-
assertThat(searchResponse.getHits().getAt(0).getFields().get("integer_field").getValue(), equalTo((Object) 3L));
917-
assertThat(searchResponse.getHits().getAt(0).getFields().get("long_field").getValue(), equalTo((Object) 4L));
918-
assertThat(searchResponse.getHits().getAt(0).getFields().get("float_field").getValue(), equalTo((Object) 5.0));
919-
assertThat(searchResponse.getHits().getAt(0).getFields().get("double_field").getValue(), equalTo((Object) 6.0d));
920-
assertThat(searchResponse.getHits().getAt(0).getFields().get("date_field").getValue(),
921-
equalTo(DateFormatter.forPattern("dateOptionalTime").format(date)));
922-
assertThat(searchResponse.getHits().getAt(0).getFields().get("boolean_field").getValue(), equalTo((Object) true));
923-
assertThat(searchResponse.getHits().getAt(0).getFields().get("text_field").getValue(), equalTo("foo"));
924-
assertThat(searchResponse.getHits().getAt(0).getFields().get("keyword_field").getValue(), equalTo("foo"));
925-
assertThat(searchResponse.getHits().getAt(0).getFields().get("binary_field").getValue(), equalTo("KmQ"));
926-
assertThat(searchResponse.getHits().getAt(0).getFields().get("ip_field").getValue(), equalTo("::1"));
927-
928892
builder = client().prepareSearch().setQuery(matchAllQuery())
929893
.addDocValueField("byte_field", "#.0")
930894
.addDocValueField("short_field", "#.0")
@@ -1029,7 +993,7 @@ public void testDocValueFieldsWithFieldAlias() throws Exception {
1029993

1030994
SearchRequestBuilder builder = client().prepareSearch().setQuery(matchAllQuery())
1031995
.addDocValueField("text_field_alias")
1032-
.addDocValueField("date_field_alias", "use_field_mapping")
996+
.addDocValueField("date_field_alias")
1033997
.addDocValueField("date_field");
1034998
SearchResponse searchResponse = builder.get();
1035999

@@ -1091,7 +1055,7 @@ public void testWildcardDocValueFieldsWithFieldAlias() throws Exception {
10911055
refresh("test");
10921056

10931057
SearchRequestBuilder builder = client().prepareSearch().setQuery(matchAllQuery())
1094-
.addDocValueField("*alias", "use_field_mapping")
1058+
.addDocValueField("*alias")
10951059
.addDocValueField("date_field");
10961060
SearchResponse searchResponse = builder.get();
10971061

0 commit comments

Comments
 (0)