Gaurav Gupta
Gaurav Gupta

Reputation: 142

Fetch distinct values of multiple fields in one SOLR query

Is there any way to query distinct values of multiple fields in single SOLR query?

I know of facet field, but it works for one field at a time.

facet:true, facet.field:XYZ

Upvotes: 0

Views: 768

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

You can provide multiple facet.field keys in your query:

facet.field=field1&facet.field=field2&facet.field=field3

The facet.field parameter identifies a field that should be treated as a facet. It iterates over each Term in the field and generate a facet count using that Term as the constraint. This parameter can be specified multiple times in a query to select multiple facet fields.

You can also provide separate settings for each field through the f.<field>.<setting> syntax:

f.field1.facet.prefix=foo

Upvotes: 1

Related Questions