Feature Pack 7 or later

Search result grouping

The Solr search result grouping feature enables grouping parent catalog entries with their underlying SKUs at query time. Products can be chosen to represent the group that is returned in search results to provide visual relevancy.

A common index field is indexed between a product and their underlying SKUs, which is used later as the grouping field. When querying the search index, grouping parameters are appended to the Solr query. As a result, the search response is structured in groups, instead of a list of Solr documents. Each group contains a list of related Solr documents. The number of rows and pagination is applied to the number of groups, instead of to the number of returned Solr documents.

The following terminology is used for search result grouping:
Grouping field
The index field name that is used for grouping.
Group value
The grouping field value that is indexed. Each group contains dedicated group values that are common between all its members.
Group
Related Solr documents that share grouping field value.
Group owner
The Solr document with a unique ID (catentry_id) that matches a grouping field value. That is, the Solr document that is returned in the final result set. Every group must have a group owner.
Group representative
The Solr document that is selected to either be the most relevant document match for the search term, or that contains a particular attribute or property value. In some instances, the group representative is selected to be returned in the final search result; orsome of its properties override the group owner properties.
Group member
Any Solr document in a group.

Group result selection process

The following diagram demonstrates the sample search group response and group owner selection process:
Sample search group response and group owner selection process
Where:
  • A search query generates seven matched Solr documents, which are grouped into three different groups.
  • Each group contains common documents that share the grouping field value.
  • The first group contains three Solr documents, 2 SKUs, and their product, the group owner. Since the group owner is returned as one of the group members, the group owner Solr document is selected to be returned in the final Solr document list.
  • The second group contains three Solr documents, all SKUs. The group owner is not among the group members. Therefore, either the first Solr document is selected to be returned in the final Solr document list, or the group owner is fetched from the index.
    The QueryMissingGroupOwner search profile query parameter controls whether to get all missing group owners in a batch call.
    Note: There are multiple reasons why the group owner might be missing from the original response. For example, the search term did not generate search hits on the product, especially if the search term matches extended product attributes where the values are only defined at the SKU-level. Or, if the group owner is filtered out because it is not published, entitled, does not match the specified search type, or has insufficient inventory count.
  • The third group contains only one Solr document, the group owner. Therefore, it is selected and added into the final Solr document list.

    If the QueryMissingGroupOwner search profile query parameter is configured to fetch missing group owners from the index, and for any reason, the group owner is not returned (for example, it is not published or entitled), the first Solr document is selected as the group owner.

  • As a result of this selection process, three out of seven Solr documents are selected and further processed by other postprocessors that are defined in the search profile.

Facet counts can be configured to either be based on the original Solr documents, or based on the number of groups.

Grouping processors and search profiles

The SolrRESTSearchResultGroupingQueryPreprocessor is used to read the grouping parameters from a search profile, and add them to the search query.

The SolrRESTSearchResultGroupingQueryPostprocessor is added as the first postprocessor to handle the search group response. The postprocessor selects only one Solr document from each group and creates a flat Solr document list to be consumed by other postprocessors. Then, the result is returned in the final REST response.

The IBM_findProductsBySearchTerm_grouping search profile can be used by the productView bySearchTermServices REST service.

The IBM_findProductsByCategory_grouping search profile can be used by the productView byCategoryId REST service.

The following snippet is a sample group configuration as defined in a search profile:

<_config:group inherits="false">
   <_config:param name="group" value="true"/>
   <_config:param name="group.limit" value="100"/>
   <_config:param name="group.facet" value="true"/>
   <_config:param name="group.sort" value="score desc"/>
   <_config:field name="grouping_parentCatentry_id"/>
</_config:group>
Where:
group
true
Grouping is enabled.
false
None of the other groupings are evaluated.
group.limit
Controls the maximum number of Solr documents to return per group.
group.facet
true
The facet count is calculated based on the number of groups.
false
The facet count is calculated based on the number of catalog entries.
group.sort
Controls how the catalog entries are sorted in each group.
field
The field name to group by.

You can add more grouping parameters by using the same group.parameter_name convention. For more information about grouping parameters, see Result Grouping / Field Collapsing.

Group representatives

There is a group representative for each search result grouping. Instead of returning the group owner, one of the SKUs or some of its properties can be returned instead, along with the group owner. Or, instead of ignoring the other group members, the price range can be found based on the group members.

The following diagram demonstrates the representative product selection process:
Sample representative product selection process
Where:
  • The first group contains four group members.
  • One of the SKUs is marked with a merchandising attribute value of Hot. That SKU is selected to be the group representative.
  • The group owner is among the group members. However, before adding the group owner to the final Solr document list, the group representative thumbnail property is used to override the group owner thumbnail property. Therefore, the group owner that is added to the final Solr document list carries some of the group representative properties.
  • The second group contains three group members, none of which is the group owner, and none of which contain the same merchandising attribute value. Therefore, the first Solr document is selected to be the group representative, as it is the most relevant.

    Similar to grouping, if QueryMissingGroupOwner search profile query parameter is configured to fetch missing group owners from the index, it is run in a batch for all groups for the current page size.

  • After the group owner is fetched, the group representative property is used to override the group owner property. Otherwise, the group representative is selected to be returned in the final Solr document list.
  • The third group, similar to grouping, contains only one group member, the group owner. Therefore, it is selected and added into the final Solr document list.
  • As a result of this selection process, three out of eight Solr documents are selected and further processed by other postprocessors that are defined in the search profile.
The following snippet is a sample representative product configuration as defined in a search profile:

<_config:heroproduct inherits="false">        		
   <_config:param name="overrideFieldName" value="thumbnail"/>
      <_config:param name="showGroupPriceRange" value="true"/>
      <_config:field name="ads_f10003" value="Hot"/> 
</_config:heroproduct> 
<_config:result inherits="true">
   <_config:field name="ads_f10003"/>
</_config:result>
Where:
overrideFieldName
Takes a list of fields to carry from the product to override the productBean default values.
ads_f10003
The field name of the search attribute.
showGroupPriceRange
Is enabled so that the price range for the entire group is shown, rather than only the product's price, if the group members contain different prices.
Field
Takes the unique field name and its value for the product, which represents the group representative. The same field must be added into the profile result returned fields to be evaluated for each catalog entry.
Note: The actual field name, in this example, represents a merchandising attribute that is assigned as a descriptive attribute to the representative SKUs.