Remove deprecated fielddata_fields from search request (#25566)
... and inner_hits
This commit is contained in:
parent
ca12b1f2a6
commit
31614c3ddb
|
@ -301,20 +301,6 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a field data based field to load and return. The field does not have to be stored,
|
|
||||||
* but its recommended to use non analyzed or numeric fields.
|
|
||||||
*
|
|
||||||
* @param name The field to get from the field data cache
|
|
||||||
* @deprecated Use {@link SearchRequestBuilder#addDocValueField(String)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SearchRequestBuilder addFieldDataField(String name) {
|
|
||||||
sourceBuilder().docValueField(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a script based field to load and return. The field does not have to be stored,
|
* Adds a script based field to load and return. The field does not have to be stored,
|
||||||
* but its recommended to use non analyzed or numeric fields.
|
* but its recommended to use non analyzed or numeric fields.
|
||||||
|
|
|
@ -64,12 +64,6 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
|
||||||
PARSER.declareBoolean(InnerHitBuilder::setVersion, SearchSourceBuilder.VERSION_FIELD);
|
PARSER.declareBoolean(InnerHitBuilder::setVersion, SearchSourceBuilder.VERSION_FIELD);
|
||||||
PARSER.declareBoolean(InnerHitBuilder::setTrackScores, SearchSourceBuilder.TRACK_SCORES_FIELD);
|
PARSER.declareBoolean(InnerHitBuilder::setTrackScores, SearchSourceBuilder.TRACK_SCORES_FIELD);
|
||||||
PARSER.declareStringArray(InnerHitBuilder::setStoredFieldNames, SearchSourceBuilder.STORED_FIELDS_FIELD);
|
PARSER.declareStringArray(InnerHitBuilder::setStoredFieldNames, SearchSourceBuilder.STORED_FIELDS_FIELD);
|
||||||
PARSER.declareField((p, i, c) -> {
|
|
||||||
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.declareStringArray(InnerHitBuilder::setDocValueFields, SearchSourceBuilder.DOCVALUE_FIELDS_FIELD);
|
||||||
PARSER.declareField((p, i, c) -> {
|
PARSER.declareField((p, i, c) -> {
|
||||||
try {
|
try {
|
||||||
|
@ -392,41 +386,6 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the docvalue fields.
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link InnerHitBuilder#getDocValueFields()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public List<String> 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<String> 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.
|
* Gets the docvalue fields.
|
||||||
*/
|
*/
|
||||||
|
@ -529,8 +488,8 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
|
||||||
}
|
}
|
||||||
if (docValueFields != null) {
|
if (docValueFields != null) {
|
||||||
builder.startArray(SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.getPreferredName());
|
builder.startArray(SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.getPreferredName());
|
||||||
for (String fieldDataField : docValueFields) {
|
for (String docValueField : docValueFields) {
|
||||||
builder.value(fieldDataField);
|
builder.value(docValueField);
|
||||||
}
|
}
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 storedFieldsContext =
|
||||||
StoredFieldsContext.fromRestRequest(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), request);
|
StoredFieldsContext.fromRestRequest(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), request);
|
||||||
if (storedFieldsContext != null) {
|
if (storedFieldsContext != null) {
|
||||||
searchSourceBuilder.storedFields(storedFieldsContext);
|
searchSourceBuilder.storedFields(storedFieldsContext);
|
||||||
}
|
}
|
||||||
String sDocValueFields = request.param("docvalue_fields");
|
String sDocValueFields = request.param("docvalue_fields");
|
||||||
if (sDocValueFields == null) {
|
|
||||||
sDocValueFields = request.param("fielddata_fields");
|
|
||||||
}
|
|
||||||
if (sDocValueFields != null) {
|
if (sDocValueFields != null) {
|
||||||
if (Strings.hasText(sDocValueFields)) {
|
if (Strings.hasText(sDocValueFields)) {
|
||||||
String[] sFields = Strings.splitStringByCommaToArray(sDocValueFields);
|
String[] sFields = Strings.splitStringByCommaToArray(sDocValueFields);
|
||||||
|
|
|
@ -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 VERSION_FIELD = new ParseField("version");
|
||||||
public static final ParseField EXPLAIN_FIELD = new ParseField("explain");
|
public static final ParseField EXPLAIN_FIELD = new ParseField("explain");
|
||||||
public static final ParseField _SOURCE_FIELD = new ParseField("_source");
|
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 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_FIELDS_FIELD = new ParseField("script_fields");
|
||||||
public static final ParseField SCRIPT_FIELD = new ParseField("script");
|
public static final ParseField SCRIPT_FIELD = new ParseField("script");
|
||||||
public static final ParseField IGNORE_FAILURE_FIELD = new ParseField("ignore_failure");
|
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;
|
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<String> fieldDataFields() {
|
|
||||||
return docValueFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the docvalue fields.
|
* Gets the docvalue fields.
|
||||||
*/
|
*/
|
||||||
|
@ -1007,10 +979,6 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
||||||
sort(parser.text());
|
sort(parser.text());
|
||||||
} else if (PROFILE_FIELD.match(currentFieldName)) {
|
} else if (PROFILE_FIELD.match(currentFieldName)) {
|
||||||
profile = parser.booleanValue();
|
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 {
|
} else {
|
||||||
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
|
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
|
||||||
parser.getTokenLocation());
|
parser.getTokenLocation());
|
||||||
|
@ -1114,11 +1082,6 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
||||||
fetchSourceContext = FetchSourceContext.fromXContent(parser);
|
fetchSourceContext = FetchSourceContext.fromXContent(parser);
|
||||||
} else if (SEARCH_AFTER.match(currentFieldName)) {
|
} else if (SEARCH_AFTER.match(currentFieldName)) {
|
||||||
searchAfterBuilder = SearchAfterBuilder.fromXContent(parser);
|
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 {
|
} else {
|
||||||
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
|
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
|
||||||
parser.getTokenLocation());
|
parser.getTokenLocation());
|
||||||
|
@ -1182,8 +1145,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
||||||
|
|
||||||
if (docValueFields != null) {
|
if (docValueFields != null) {
|
||||||
builder.startArray(DOCVALUE_FIELDS_FIELD.getPreferredName());
|
builder.startArray(DOCVALUE_FIELDS_FIELD.getPreferredName());
|
||||||
for (String fieldDataField : docValueFields) {
|
for (String docValueField : docValueFields) {
|
||||||
builder.value(fieldDataField);
|
builder.value(docValueField);
|
||||||
}
|
}
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -712,7 +712,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
||||||
indexRandom(true, client().prepareIndex("test", "type", "1").setSource("test_field", "foobar"));
|
indexRandom(true, client().prepareIndex("test", "type", "1").setSource("test_field", "foobar"));
|
||||||
refresh();
|
refresh();
|
||||||
SearchResponse searchResponse = client().prepareSearch("test").setTypes("type").setSource(
|
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);
|
assertHitCount(searchResponse, 1);
|
||||||
Map<String, DocumentField> fields = searchResponse.getHits().getHits()[0].getFields();
|
Map<String, DocumentField> fields = searchResponse.getHits().getHits()[0].getFields();
|
||||||
assertThat(fields.get("test_field").getValue(), equalTo("foobar"));
|
assertThat(fields.get("test_field").getValue(), equalTo("foobar"));
|
||||||
|
|
|
@ -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 `postings` highlighter has been removed from Lucene and Elasticsearch.
|
||||||
The `unified` highlighter outputs the same highlighting when `index_options` is set
|
The `unified` highlighter outputs the same highlighting when `index_options` is set
|
||||||
to `offsets`.
|
to `offsets`.
|
||||||
|
|
||||||
|
==== `fielddata_fields`
|
||||||
|
|
||||||
|
The deprecated `fielddata_fields` have now been removed. `docvalue_fields` should be used instead.
|
||||||
|
|
|
@ -46,10 +46,6 @@
|
||||||
"type" : "list",
|
"type" : "list",
|
||||||
"description" : "A comma-separated list of fields to return as the docvalue representation of a field for each hit"
|
"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": {
|
"from": {
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
"description" : "Starting offset (default: 0)"
|
"description" : "Starting offset (default: 0)"
|
||||||
|
|
|
@ -132,7 +132,7 @@ setup:
|
||||||
- is_true: hits.hits.0._source
|
- is_true: hits.hits.0._source
|
||||||
|
|
||||||
---
|
---
|
||||||
"fielddata_fields":
|
"docvalue_fields":
|
||||||
- do:
|
- do:
|
||||||
search:
|
search:
|
||||||
docvalue_fields: [ "count" ]
|
docvalue_fields: [ "count" ]
|
||||||
|
|
Loading…
Reference in New Issue