diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java index 0333092b917..8b9879b2fa2 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java @@ -301,20 +301,6 @@ public class SearchRequestBuilder extends ActionRequestBuilder { - throw new ParsingException(p.getTokenLocation(), "The field [" + - SearchSourceBuilder.FIELDS_FIELD + "] is no longer supported, please use [" + - SearchSourceBuilder.STORED_FIELDS_FIELD + "] to retrieve stored fields or _source filtering " + - "if the field is not stored"); - }, SearchSourceBuilder.FIELDS_FIELD, ObjectParser.ValueType.STRING_ARRAY); PARSER.declareStringArray(InnerHitBuilder::setDocValueFields, SearchSourceBuilder.DOCVALUE_FIELDS_FIELD); PARSER.declareField((p, i, c) -> { try { @@ -392,41 +386,6 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl return this; } - /** - * Gets the docvalue fields. - * - * @deprecated Use {@link InnerHitBuilder#getDocValueFields()} instead. - */ - @Deprecated - public List getFieldDataFields() { - return docValueFields; - } - - /** - * Sets the stored fields to load from the docvalue and return. - * - * @deprecated Use {@link InnerHitBuilder#setDocValueFields(List)} instead. - */ - @Deprecated - public InnerHitBuilder setFieldDataFields(List fieldDataFields) { - this.docValueFields = fieldDataFields; - return this; - } - - /** - * Adds a field to load from the docvalue and return. - * - * @deprecated Use {@link InnerHitBuilder#addDocValueField(String)} instead. - */ - @Deprecated - public InnerHitBuilder addFieldDataField(String field) { - if (docValueFields == null) { - docValueFields = new ArrayList<>(); - } - docValueFields.add(field); - return this; - } - /** * Gets the docvalue fields. */ @@ -529,8 +488,8 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl } if (docValueFields != null) { builder.startArray(SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.getPreferredName()); - for (String fieldDataField : docValueFields) { - builder.value(fieldDataField); + for (String docValueField : docValueFields) { + builder.value(docValueField); } builder.endArray(); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 115c86dda5d..3f04603c2da 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -161,23 +161,12 @@ public class RestSearchAction extends BaseRestHandler { } } - if (request.param("fields") != null) { - throw new IllegalArgumentException("The parameter [" + - SearchSourceBuilder.FIELDS_FIELD + "] is no longer supported, please use [" + - SearchSourceBuilder.STORED_FIELDS_FIELD + "] to retrieve stored fields or _source filtering " + - "if the field is not stored"); - } - - StoredFieldsContext storedFieldsContext = StoredFieldsContext.fromRestRequest(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), request); if (storedFieldsContext != null) { searchSourceBuilder.storedFields(storedFieldsContext); } String sDocValueFields = request.param("docvalue_fields"); - if (sDocValueFields == null) { - sDocValueFields = request.param("fielddata_fields"); - } if (sDocValueFields != null) { if (Strings.hasText(sDocValueFields)) { String[] sFields = Strings.splitStringByCommaToArray(sDocValueFields); diff --git a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 3f3be7b35d1..37c7f3051fc 100644 --- a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -85,9 +85,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ public static final ParseField VERSION_FIELD = new ParseField("version"); public static final ParseField EXPLAIN_FIELD = new ParseField("explain"); public static final ParseField _SOURCE_FIELD = new ParseField("_source"); - public static final ParseField FIELDS_FIELD = new ParseField("fields"); public static final ParseField STORED_FIELDS_FIELD = new ParseField("stored_fields"); - public static final ParseField DOCVALUE_FIELDS_FIELD = new ParseField("docvalue_fields", "fielddata_fields"); + public static final ParseField DOCVALUE_FIELDS_FIELD = new ParseField("docvalue_fields"); public static final ParseField SCRIPT_FIELDS_FIELD = new ParseField("script_fields"); public static final ParseField SCRIPT_FIELD = new ParseField("script"); public static final ParseField IGNORE_FAILURE_FIELD = new ParseField("ignore_failure"); @@ -755,33 +754,6 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ return storedFieldsContext; } - - /** - * Adds a field to load from the docvalue and return as part of the - * search request. - * - * @deprecated Use {@link SearchSourceBuilder#docValueField(String)} instead. - */ - @Deprecated - public SearchSourceBuilder fieldDataField(String name) { - if (docValueFields == null) { - docValueFields = new ArrayList<>(); - } - docValueFields.add(name); - return this; - } - - /** - * Gets the docvalue fields. - * - * @deprecated Use {@link SearchSourceBuilder#docValueFields()} instead. - */ - @Deprecated - public List fieldDataFields() { - return docValueFields; - } - - /** * Gets the docvalue fields. */ @@ -1007,10 +979,6 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ sort(parser.text()); } else if (PROFILE_FIELD.match(currentFieldName)) { profile = parser.booleanValue(); - } else if (FIELDS_FIELD.match(currentFieldName)) { - throw new ParsingException(parser.getTokenLocation(), "Deprecated field [" + - SearchSourceBuilder.FIELDS_FIELD + "] used, expected [" + - SearchSourceBuilder.STORED_FIELDS_FIELD + "] instead"); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", parser.getTokenLocation()); @@ -1114,11 +1082,6 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ fetchSourceContext = FetchSourceContext.fromXContent(parser); } else if (SEARCH_AFTER.match(currentFieldName)) { searchAfterBuilder = SearchAfterBuilder.fromXContent(parser); - } else if (FIELDS_FIELD.match(currentFieldName)) { - throw new ParsingException(parser.getTokenLocation(), "The field [" + - SearchSourceBuilder.FIELDS_FIELD + "] is no longer supported, please use [" + - SearchSourceBuilder.STORED_FIELDS_FIELD + "] to retrieve stored fields or _source filtering " + - "if the field is not stored"); } else { throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", parser.getTokenLocation()); @@ -1182,8 +1145,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ if (docValueFields != null) { builder.startArray(DOCVALUE_FIELDS_FIELD.getPreferredName()); - for (String fieldDataField : docValueFields) { - builder.value(fieldDataField); + for (String docValueField : docValueFields) { + builder.value(docValueField); } builder.endArray(); } diff --git a/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java b/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java index 5ae26875858..8c25c64874f 100644 --- a/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java +++ b/core/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java @@ -712,7 +712,7 @@ public class SearchFieldsIT extends ESIntegTestCase { indexRandom(true, client().prepareIndex("test", "type", "1").setSource("test_field", "foobar")); refresh(); SearchResponse searchResponse = client().prepareSearch("test").setTypes("type").setSource( - new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()).fieldDataField("test_field")).get(); + new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()).docValueField("test_field")).get(); assertHitCount(searchResponse, 1); Map fields = searchResponse.getHits().getHits()[0].getFields(); assertThat(fields.get("test_field").getValue(), equalTo("foobar")); diff --git a/docs/reference/migration/migrate_6_0/search.asciidoc b/docs/reference/migration/migrate_6_0/search.asciidoc index 0a6db5cacad..6d0a7fa4470 100644 --- a/docs/reference/migration/migrate_6_0/search.asciidoc +++ b/docs/reference/migration/migrate_6_0/search.asciidoc @@ -111,4 +111,8 @@ It is still possible to force the highlighter to `fvh` or `plain` types. The `postings` highlighter has been removed from Lucene and Elasticsearch. The `unified` highlighter outputs the same highlighting when `index_options` is set - to `offsets`. \ No newline at end of file + to `offsets`. + +==== `fielddata_fields` + +The deprecated `fielddata_fields` have now been removed. `docvalue_fields` should be used instead. diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/search.json b/rest-api-spec/src/main/resources/rest-api-spec/api/search.json index 0519a923806..5b4b9b681d5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/search.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/search.json @@ -46,10 +46,6 @@ "type" : "list", "description" : "A comma-separated list of fields to return as the docvalue representation of a field for each hit" }, - "fielddata_fields": { - "type" : "list", - "description" : "A comma-separated list of fields to return as the docvalue representation of a field for each hit" - }, "from": { "type" : "number", "description" : "Starting offset (default: 0)" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/10_source_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/10_source_filtering.yml index c8f6871295e..3830a68b28f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/10_source_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/10_source_filtering.yml @@ -132,7 +132,7 @@ setup: - is_true: hits.hits.0._source --- -"fielddata_fields": +"docvalue_fields": - do: search: docvalue_fields: [ "count" ]