Griff Griff - 1 year ago 117
Java Question

How to specify multiple Spring Data Solr Facet Fields?

According to the spring data solr docs, you can specify facet fields by either using annotations or using the Java API that solr data provides. In the annotation, you can specify multiple facet fields as such:

@Facet(fields = { "clientCode", "state", "productCode"}, limit = 10, minCount= 1)

From the documentation:

Example 2.6.

// produces:
FacetOptions options = new FacetOptions();
options.addFacetOnField(new FieldWithFacetParameters("name").setPrefix("spring"));

How do I add multiple facets using FacetOptions?

It looks like you can only add a single Facet to the query.

Answer Source

You can call addFacetOnField method multiple times to add facets on multiple fields.

options.addFacetOnField(new FieldWithFacetParameters("name").setPrefix("spring")); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download