2014-11-22 206 views
0
public FacetPage<SolrArticleDocument> facetSearch(String searchTerm, Pageable page) { 
    SimpleFacetQuery facetQuery = new SimpleFacetQuery(new SimpleStringCriteria(searchTerm)); 
    Sort sort = new Sort(Direction.DESC,"trendingCount"); 
    facetQuery.addSort(sort); 
    FacetOptions options = new FacetOptions(); 
    options.addFacetOnFlieldnames(getFacetFields()); 
    facetQuery.setFacetOptions(options); 
    facetQuery.setPageRequest(page); 
    return cmsTemplate.queryForFacetPage(facetQuery, SolrArticleDocument.class); 
} 

使用上面的方法,只返回10条记录,但有望走出回报是所有记录..Solr的搜索中使用的方法queryForFacetPage只有10条记录返回

回答

0

我猜你正在使用Spring数据Solr的框架从你的方法名称。在这里,您可以set the facet.limit option through setFacetLimit,默认为10.这设置每个方面返回的条款数。您可以将该值设置为负值以返回所有条款,但是如果您需要一定数量的条款 - 请使用特定值,以便Lucene可以尽可能缩短构建构面。

0
facetQuery.setRows(999); // or any other big number =/ 

不如你所期望的那么好,但它确实有效。