我正在尝试向Spring数据Solr搜索添加排序条件。
我已经看到了对搜索结果进行排序的方法(从Solr接收到数据后的List <> ..),但是没有为查询中的Solr指定排序顺序的方法。 Solr查询应该看起来像....
http://localhost:8088/solr/books/select?fl=fullrecord%2C%20url&q=mod_date%3A%5B2012-04-17T11%3A38%3A15Z%20TO%20NOW%5D&sort=mod_date%20asc
我需要在Solr中执行 ,因为请求是分页的(可能有成千上万的结果),因此每个查询仅返回有限数量的结果(一页)。 如何添加“&sort = mod_date asc” solr查询字符串?
// Catalog.findByDateChanged=mod_date:[?0 TO ?1]
public interface CatalogRepository extends SolrCrudRepository<CatalogDoc, String> {
@Query(name = "Catalog.findByDateChanged", fields = { "fullrecord", "url" })
public Page<CatalogDoc> findByDateChanged(String fromDate, String toDate, Pageable pageable);
}
答案 0 :(得分:0)
似乎可以将排序添加到通话中...
bash
奇怪的是,它两次将其添加到Solr的命令中...
Page<CatalogDoc> results = solrRepo.findByDateChanged(from, to,
PageRequest.of(pageNo, perPage, Sort.Direction.ASC, "mod_date" ));