Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

22.5. Search

		
	@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;
	}