zoukankan      html  css  js  c++  java
  • 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;
  • 相关阅读:
    python之字典方法
    python之字符串方法
    python strip()方法使用
    Airtest自动化测试工具介绍
    selenium 环境配置
    一个自定义线程池的小Demo
    简单工厂模式
    BootStrap入门_创建第一个例子
    MongoDB的索引
    MongoDB的查询
  • 原文地址:https://www.cnblogs.com/margin-gu/p/7039399.html
Copyright © 2011-2022 走看看