@Query(value = "(?0) -no:?1 +typeCode:?2", fields = { "no", "typeName", "name", "keywords", "modifyDate", "score" }, name = "TodoDocument.findByNamedQuery", requestHandler = "select")
List<T> findScore(String keywords, String no, String typeCode, Pageable page);spa
@Test
public void findScore() {
String no = "33029100001";
// 得到信息
Case _entity = caseService.findById(no);
// 得到關鍵詞列表
List<String> keyword = keywordsService.findListByCaseId(_entity.getNo());code
String keywords = String.join(" keywords:", keyword);
keywords = "keywords:" + keywords.trim();blog
//排序排序
Sort sort = new Sort(Sort.Direction.DESC, "score").and(new Sort(Sort.Direction.DESC, "modifyDate"));get
//分頁
Pageable page = new PageRequest(0, 10, sort);
List<T> list = keywordRepository.findScore(keywords, _entity.getNo(), _entity.getTypeCode(), page);it
System.out.println("list size :" + list.size());
}io
@Field() @Indexed() private String keywords; @Field() @Indexed() private Long modifyDate; @Score() private Double score;