Feature Pack 5

Enabling search result grouping in Feature Pack 5

You can enable search result grouping on your Feature Pack 5 environment.

Before you begin

Install the cumulative interim fix for Feature Pack 5, JR53048.fep.

About this task

Interim fix JR44172 provides runtime enablement modifications to your Feature Pack 5 environment to allow you to build customization code for search result grouping. For more information, see Search result grouping. The search result grouping feature was introduced in Feature Pack 7 but you can use this topic as an example for how to customize your Feature Pack 5 store to leverage this feature.

Procedure

  1. Go to the Apache Solr official website and download the following JAR files from the Apache Solr 3.5 package:
    • apache-solr-clustering-3.5.0.jar
    • carrot2-core-3.5.0.jar
    • commons-lang-2.4.jar
    • hppc-0.3.4-jdk15.jar
    • jackson-core-asl-1.5.2.jar
    • jackson-mapper-asl-1.5.2.jar
    • mahout-collections-0.3.jar
    • mahout-math-0.3.jar
    • simple-xml-2.4.1.jar
  2. Save the JAR files to the Solr.war/WEB-INF/lib directory.
  3. In each of the CatalogEntry core's solrconfig.xml file that resides under your solrhome/MC_masterCatalogId/localeName/CatalogEntry/conf/ directory, remove the "enable" attribute from the searchComponent called "clustering":
    <searchComponent name="clustering" class="solr.clustering.ClusteringComponent" >
  4. Open your search profile:
    • For IBM i OS operating systemSolarisLinuxAIXWindowsWC_eardir/xml/config/com.ibm.commerce.catalog-fep/wc-search.xml
    • WebSphere Commerce Developerworkspace_dir/WC//xml/config/com.ibm.commerce.catalog-fep/wc-search.xml
  5. Use the following guideline to add the <_config:group> tag to your search profile:
    • The group section declares the result grouping field and parameter options. A limit parameter specifies the maximum number of results to return for each group. The default value is 1.

      For example, <_config:param name="limit" value="99"/>

    • Then, list the field names by which to group results. This field must be single-valued, and either be indexed or a field type that has a value source and works in a function query. It must also be a string-based field.

      For example, <_config:field name="mfName_ntk_cs" />

    • The following example is the final result of the sample configuration that you can add to your wc-search.xml search profile file:
      <_config:group > 
      	<_config:param name="limit" value="99"/> 
      	<_config:field name="mfName_ntk_cs" /> 
      </_config:group >

    By using this result grouping configuration, each of the search results is tagged with a "groupname" and "groupvalue" in its metadata property. These two properties can be used at the storefront to group similar results together for display. Using the previous example, when grouping by brand name, a product of brand ABC is tagged with "groupname=mfName_ntk_cs" and "groupvalue=ABC". To retrieve this value, use JSP expression language. For example: ${catalogEntryView.metaData.groupname} or ${catalogEntryView.metaData.groupvalue}.

    The total number of matches and the number of groups that found matches, can be found from CatalogNavigationView's metadata map: "groupmatch" and "groupcount".
    Note: The "start" and "rows" parameters are repurposed for this grouping feature. When used in a grouped query, "start" refers to the group offset and "rows" refers to the number of groups to return.
    Restriction: Solr 3.5 does not support paginating at the group level. Also, it is recommended not to mix paging and grouping results together in a single search request.