@Document(indexName="zhunneng",type="plan")
@Field(index = true, store = true, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word", type = FieldType.text)
//搜索
@RequestMapping("search")
public String search(String keyword,@RequestParam(defaultValue="1")Integer pageNum ,@RequestParam(defaultValue="2")Integer pageSize ,Model model) {
//需求,使用es做搜索
//1.導入依賴(已經導入)
//2.配置文件(讓spring的配置加載es.xml)
//3.修改xml,指定倉庫接口包掃描位置,
//4.編寫倉庫接口,繼承ElasticSearchRepository的接口,就具備了CRUD的功能
//5.在實體類上執行對應的庫名表名,主鍵,搜索關鍵字(注解)
//6.得把mysql的數據導入到es索引庫
//使用工具類搜索
PageInfo<Plan> info = (PageInfo<Plan>) HLUtils.findByHighLight(elasticsearchTemplate, Plan.class, pageNum, pageSize, new String[] {"manager","name","content"}, "id", keyword);
model.addAttribute("info", info);
model.addAttribute("key", keyword);
return "search";
}