Extend the WebSphere Commerce search configuration file (wc-search.xml) to support the warranty type suggestion group

Feature Pack 4Feature Pack 3In this lesson, you extend the wc-search.xml file to return warranty type data to the cached auto-suggest menu. The extension includes registering the Java class that you created in the previous lesson, and extending two existing search profiles.To review information about the wc-search.xml file and search profiles, see WebSphere Commerce search configuration file (wc-search.xml) (WC EAR).

About this task

The first change that you must make in your custom wc-search.xml file is to register a new handler for the new warranty type data.
Then, you must extend two existing search profiles:
  • IBM_findNavigationSuggestions search profile
  • IBM_findCatalogEntryByNameAndShortDescription search profile

Procedure

  1. Add a search profile to add a suggestion group for warranty terms:
    1. Open your custom wc-search.xml file in the WC/xml/config/com.ibm.commerce.catalog-ext directory.
      Note: You created this custom file in the prerequisite tutorials.
    2. Locate the following line of code:
      </_config:search-config> 
      
    3. Above the </_config:search-config> element, insert the following lines of code:
      	<_config:profile indexName="CatalogEntry" name="x_IBM_findNavigationSuggestions" extends="IBM_findNavigationSuggestions">
      				<_config:navigationSuggestion>
      					<_config:suggestion handler="com.mycompany.commerce.search.WarrantySuggestion" name="myID" />
      				</_config:navigationSuggestion>
      			</_config:profile>
    4. Save the file but do not close it.
  2. Copy the navigation suggestions definition from the default wc-search.xml file into your custom file:
    1. Go to the WC/xml/config/com.ibm.commerce.catalog-fep directory.
    2. Open the default WebSphere Commerce search configuration file, wc-search.xml.
    3. Find the definition of the IBM_findNavigationSuggestions profile, as shown here:
      
      <_config:profile indexName = "CatalogEntry" name = "IBM_findNavigationSuggestions">
          <_config:query>
              <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchIndexNameValidator"/>
              <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchNoSearchResultsExpressionProvider"/>
              <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchExpressionValidator"/>
          </_config:query>
          <_config:result>
              <_config:filter classname = "com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter"/>
          </_config:result>
      
          <_config:navigationSuggestion>
      
      A
              <_config:suggestion name = "Category" handler = "com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.CategoryNavigationSuggestion"/>
              <_config:suggestion name = "Brand" handler = "com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.BrandNavigationSuggestion"/>
              <_config:suggestion name = "Articles" handler = "com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.WebContentNavigationSuggestion">
                  <_config:param name = "totalNumber" value = "100"/>
              </_config:suggestion>
      
      B
          </_config:navigationSuggestion>
      
      </_config:profile>
    4. Copy the XML node that begins with A and ends with B into your custom wc-search.xml file. In the file, copy the node to the location shown here:
      <_config:profile indexName="CatalogEntry" name="x_IBM_findNavigationSuggestions" extends="IBM_findNavigationSuggestions">
      				<_config:navigationSuggestion>
      					<_config:suggestion handler="com.mycompany.commerce.search.WarrantySuggestion" name="myID" />
      **********************COPY HERE**************************
      				</_config:navigationSuggestion>
      			</_config:profile>
    5. Save the file but do not close it.
  3. Create a search profile to fetch all warranty type information through a search request:
    1. In your custom wc-search.xml file, locate the following line of code:
      </_config:search-config> 
      
    2. Above the </_config:search-config> element, insert the following new profile:
      <_config:profile extends = "IBM_extensionProfile" name = "x_MyCompany_findNavigationSuggestion_Warranty">
         <_config:query inherits = "false">
            <_config:param name = "debug" value = "false"/>
            <_config:param name = "maxRows" value = "100"/>
            <_config:param name = "maxTimeAllowed" value = "5000"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProfileNameValidator"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchIndexNameValidator"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByStorePathExpressionProvider"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByCategoryExpressionProvider"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchFacetConditionExpressionProvider"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByPublishedEntryOnlyExpressionProvider"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchTypeExpressionProvider"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProductEntitlementExpressionProvider"/>
            <_config:provider classname = "com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchExpressionValidator"/>
         </_config:query>
         <_config:facets inherits = "false">
            <_config:param name = "sort" value = "index"/>
            <_config:param name = "minCount" value = "1"/>
            <_config:param name = "limit" value = "100"/>
            <_config:category scope = "all">
               <_config:facet name = "*"/>
            </_config:category>
         </_config:facets>
      </_config:profile>
    3. Save the file but do not close it.
  4. Create a search profile to search against the warranty information and return the catalog entries that match the warranty type that the customer searched for:
    Note: The search profile findCatalogEntryByWarranty was already added in the prerequisite tutorial,Adding the new search profile
    1. Open your custom wc-search.xml file in the WC/xml/config/com.ibm.commerce.catalog-ext directory.
    2. Locate the following line of code:
      <_config:profile name="X_findCatalogEntryByWarranty"
      extends="IBM_findCatalogEntryByNameAndShortDescription">
       <_config:query inherits="true">
    3. Change the line <_config:query inherits="true"> from true to false
    4. Insert the following code right after the line <_config:query inherits="false">:
        <_config:param name="debug" value="false"/>
        <_config:param name="maxRows" value="100"/>
        <_config:param name="maxTimeAllowed" value="5000"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProfileNameValidator"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchIndexNameValidator"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByKeywordExpressionProvider"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByStorePathExpressionProvider"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByCategoryExpressionProvider"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchByPublishedEntryOnlyExpressionProvider"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchTypeExpressionProvider"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProductEntitlementExpressionProvider"/>
        <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchExpressionValidator"/>
        <_config:field name="wartype" />
       </_config:query>
      </_config:profile>        
    5. Save and close the file.

Results

For your reference, the compressed file that you downloaded at the beginning of this tutorial contains a custom wc-search.xml file with the changes in this lesson.