How to specify multiple Spring Data Solr Facet Fields?

1.1k views Asked by At

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: f.name.facet.prefix=spring
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.

1

There are 1 answers

0
user5064494 On BEST ANSWER

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

options.addFacetOnField(new FieldWithFacetParameters("name").setPrefix("spring"));