问题
When declaring this method:
@Query(value = "*:*")
@Facet(pivotFields = {"type","status"}, limit = 10000)
FacetPage<SolrCrimeServer> findAllAndFacetOnTypeAndStatus(Pageable page);
I get
java.lang.IllegalStateException: 2 or more fields required for pivot facets at org.springframework.util.Assert.state(Assert.java:385) at org.springframework.data.solr.core.query.FacetOptions.addFacetOnPivot(FacetOptions.java:150) at org.springframework.data.solr.repository.query.AbstractSolrQuery.extractFacetOptions(AbstractSolrQuery.java:246) at org.springframework.data.solr.repository.query.AbstractSolrQuery.execute(AbstractSolrQuery.java:120)
With version
1.1.1.RELEASE
Thanks.
回答1:
The pivotFields
attribute of @Facet
takes at least a tuple of field names within one argument.
@Facet(pivotFields={"type,status"}, limit=10000)
You can have a look at SolrQueryMethodTests. Additionally you may vote for this issue.
来源:https://stackoverflow.com/questions/22961464/how-to-facet-pivot-with-spring-data-solr