2

How is it possible to add a facet pivot using solrTemplate with spring-solr-data?

This question is related to How to facet.pivot with spring-data-solr but I am looking for a solution using solrTemplate.

Community
  • 1
  • 1
lizzie
  • 1,506
  • 1
  • 18
  • 31

1 Answers1

4

Please have a look at ITestSolrTemplate.java#L451.

FacetQuery query = new SimpleFacetQuery(new Criteria("*").expression("*"));
query.setFacetOptions(new FacetOptions().addFacetOnPivot("category", "name"));

FacetPage<SolrBean> page = solrTemplate.queryForFacetPage(query, SolrBean.class);
Christoph Strobl
  • 6,491
  • 25
  • 33
  • I have one more problem with facets, I want to set facet.limit to -1. Whenever I use setFacetLimit(-1) it get facet.limit=1 in the query. Do you have any suggestion? – lizzie Mar 26 '15 at 08:20
  • There seems to be a bug in `DefaultQueryParser` using the pageable instead of the _int_ param of `FacetOptions`. Sorry for the inconvenience! would you mind filing a bug report in the projects [jira](https://jira.spring.io/browse/DATASOLR) – Christoph Strobl Mar 26 '15 at 08:36