Search fix: fielddata_fields query string parameter was ignored.

The RestSearchAction did not parse the fielddata_fields parameter. Added test case and missing parser code.

Closes #11025
This commit is contained in:
markharwood 2015-05-27 12:52:13 +01:00
parent 7fbd86aa97
commit 57653df713
2 changed files with 20 additions and 0 deletions

View File

@ -90,3 +90,9 @@
- match: { hits.hits.0.fields: { include.field2 : [v2] }}
- is_true: hits.hits.0._source
- do:
search:
fielddata_fields: ["count"]
- match: { hits.hits.0.fields.count: [1] }

View File

@ -195,6 +195,20 @@ public class RestSearchAction extends BaseRestHandler {
}
}
}
String sFieldDataFields = request.param("fielddata_fields");
if (sFieldDataFields != null) {
if (searchSourceBuilder == null) {
searchSourceBuilder = new SearchSourceBuilder();
}
if (Strings.hasText(sFieldDataFields)) {
String[] sFields = Strings.splitStringByCommaToArray(sFieldDataFields);
if (sFields != null) {
for (String field : sFields) {
searchSourceBuilder.fieldDataField(field);
}
}
}
}
FetchSourceContext fetchSourceContext = FetchSourceContext.parseFromRestRequest(request);
if (fetchSourceContext != null) {
if (searchSourceBuilder == null) {