java spring-data-solr 查詢 排序 分頁


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

@Test
public void findScore() {
  String no = "33029100001";
  // 獲得信息
  Case _entity = caseService.findById(no);
  // 獲得關鍵詞列表
  List<String> keyword = keywordsService.findListByCaseId(_entity.getNo());

  String keywords = String.join(" keywords:", keyword);
  keywords = "keywords:" + keywords.trim();

  //排序

  Sort sort = new Sort(Sort.Direction.DESC, "score").and(new Sort(Sort.Direction.DESC, "modifyDate"));

  //分頁
  Pageable page = new PageRequest(0, 10, sort);
  List<T> list = keywordRepository.findScore(keywords, _entity.getNo(), _entity.getTypeCode(), page);

  System.out.println("list size :" + list.size());
}

    @Field()
    @Indexed()
    private String keywords;

    @Field()
    @Indexed()
    private Long modifyDate;
    
    @Score()
    private Double score;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM