@RequestMapping(value = "/article/list")
public List<Map<String, Object>> list() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
SearchResponse response = client.prepareSearch("information").setTypes("article")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH).addSort("ctime", SortOrder.DESC)
.setFrom(0).setSize(60).setExplain(true).get();
for (final SearchHit hit : response.getHits().getHits()) {
System.out.println(hit.getSourceAsString());
hit.getSourceAsMap().remove("content");
list.add(hit.getSourceAsMap());
}
return list;
}
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。