
Field faceting
In Solr the most straightforward kind of faceting is field faceting, in which Solr’s FacetComponent computes the top values for a field and returns the list of those values along with a count of the subset of documents in the search results which match that term. Field faceting works best over fields which contain a single label or set of labels from a finite, controlled lexicon such as product category. Fusion’s Facet Query Stage can be used to configure field faceting as part of the search query pipeline.Range faceting
Range facets are used for fields which contain date or number values. Values can be grouped into ranges by specifying additional query parameters. To configure range faceting, use the Additional Query Parameters Stage to specify Solr range faceting parameters.LucidAcademyLucidworks offers free training to help you get started.The Quick Learning for Configuring Range Facets focuses on how to group values into ranges for faceting:Visit the LucidAcademy to see the full training catalog.
JSON faceting
In eCommerce, one product often contains multiple SKUs. In this case, it’s ideal to group search results on the product ID, such that only one result for all SKUs of a given product will be returned. This is achieved by using theunique
parameter in JSON facets. You can use JSON facets by creating Query Params in a Create a Query Profile or with the Additional Query Parameters Stage in a Query Pipeline.
Create a Query Profile
Create a Query Profile
- In the Fusion workspace, navigate to Querying > Query Profiles.
- Click New. The Add Query Profile panel appears:

-
Enter a search mode to use with this profile.
-
dsl
(Domain Specific Language) uses expressive search queries and responses via a structured, modern JSON format. -
legacy
primarily uses Solr parameters. See the Solr Query Language cheat sheet. -
all
uses both DSL and legacy search modes. This is the default value. The default value ofall
works well for most use cases.The Search Mode field is available for Fusion 5.4.x and later.
-
- Enter a Query Profile ID.
- Select a query pipeline to associate with this profile.
-
Enter a Solr search handler to use with this profile.
The default of
select
works well for most use cases. - Select a collection to associate with this profile.
- Optionally, click New params… to enter Solr request parameters to add to the request URL when submitting queries using this profile.
-
Optionally, select Enable experimentation to configure this profile for use with experiments.
- Select the percentage of experiment traffic to direct to this profile.
- Select the experiment to associate with this profile, or select Add Experiment to configure a new one.
- Click Save.
LucidAcademyLucidworks offers free training to help you get started.The Course for Index and Query Profiles focuses on how index and query profiles operate, and how to configure and manage them:Visit the LucidAcademy to see the full training catalog.
JSON faceting example
For example, if a product is available in SKUs of multiple colors, the following should apply:- All available colors (in any SKU in the result set) are represented in the facets
- The
count
for those facets reflects matching product counts, not SKU counts.
SKU | Product | Color |
---|---|---|
Sku11 | Prod1 | Red |
Sku12 | Prod1 | Blue |
Sku13 | Prod1 | Blue |
Sku14 | Prod1 | Blue |
Sku21 | Prod2 | Red |
Sku22 | Prod2 | Blue |
Sku23 | Prod2 | Green |
Sku24 | Prod2 | Green |
Facet stats
The Stats component is useful for computing statistics against fields within your document set. For example, when performing a query, you can invoke the Stats component to return information about themean
price of a product or determine how many documents are missing a particular field.
Facet stats example
Faceting concepts
Key Facet Concepts:- Term: A specific value from a field.
- Limit: The maximum number of terms to be returned.
- Offset: The number of top facet values to skip in the response (just like paging through search results and choosing an offset of 51 to start on page 2 when showing 50 results per page).
-
Sort: The order in which to list facet values:
count
ordering is by documents per term, descending, andindex
ordering is sorted on term values themselves. - Missing: The number of documents in the results set which have no value for the facet field.
-
Choice of facet method (advanced): Specify Solr algorithm used to calculate facet counts. (See Facet Method Configuration for details).
One of:enum
. Small number of distinct categories.fc
(“field cache”). Many different values in the field, each document has low number of values, multi-valued field.fcs
(“single value string fields”). Good for rapidly changing indexes.
Additional resources
- https://lucidworks.com/post/pivot-facets-inside-and-out/
- https://lucidworks.com/post/apache-solr-statistics/
- https://lucidworks.com/post/pivoting-to-the-query-using-pivot-facets-to-build-a-multi-field-suggester/
LucidAcademyLucidworks offers free training to help you get started.The Course for Faceting focuses on how to use facets to ensure faster, smarter search results:Visit the LucidAcademy to see the full training catalog.