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:
parent
7fbd86aa97
commit
57653df713
|
@ -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] }
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue