我在使用java 对elasticsearch 进行聚合查询,并对某个字段进行排序时,报错了 ,Java代码如下:public Map searchOnParamByPage(ElasticsearchConfig elasticsearchConfig,
String[] indices,
String sortField,
String fieldKey,
String fieldVal,
int from, int size) throws IOException
{
SearchRequest searchRequest = new SearchRequest(indices);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(QueryBuilders.matchPhraseQuery(fieldKey, fieldVal));
sourceBuilder.from(from);
sourceBuilder.size(size);
sourceBuilder.timeout(new TimeValue(1000));
sourceBuilder.trackTotalHits(true);
sourceBuilder.sort(new FieldSortBuilder(sortField).order(SortOrder.DESC));
searchRequest.source(sourceBuilder);
if (client == null) {
initClient(elasticsearchConfig);
}
SearchResponse searchResponse = client
.search(searchRequest,
RequestOptions.DEFAULT);
SearchHits hits = searchResponse.getHits();
TotalHits totalHits = hits.getTotalHits();
long totalSize = totalHits.value;
SearchHit[] searchHits = hits.getHits();
Map resultMap = new HashMap();
List> resultList = new ArrayList>();
Map sourceMap = null;
for (SearchH