Changing the default search type

The search type controls the search scope of different catalog entry types to be searched and displayed in the storefront. It also controls the search operation that is used for multiple keyword search terms such as the AND operator, OR operator, and exact match.

About this task

The default search type is 1000: ANY (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs). It can be set in the following locations:
  • In the search profile, which sets the default value and results in all REST requests to use the same value that is set for the profile.
  • In the REST request, which overrides the default value, and any other value set at the profile level.

Procedure

  1. Determine which search type you want to set by using the following table as a reference:
    OptionDescription
    0 ANY (INCLUDE products, kits, bundles, EXCLUDE product level SKUs, and category level SKUs)
    1 EXACT (INCLUDE products, kits, bundles, EXCLUDE product level SKUs, and category level SKUs)
    2 ALL (INCLUDE products, kits, bundles, EXCLUDE product level SKUs, and category level SKUs)
    3 NONE (INCLUDE products, kits, bundles, EXCLUDE product level SKUs, and category level SKUs)
    10 ANY (INCLUDE products, kits, bundles, product level SKUs, category level SKUs)
    11 EXACT (INCLUDE products, kits, bundles, product level SKUs, category level SKUs)
    12 ALL (INCLUDE products, kits, bundles, product level SKUs, category level SKUs)
    13 NONE (INCLUDE products, kits, bundles, product level SKUs, category level SKUs)
    100 ANY (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, kits, bundles)
    101 EXACT (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, kits, bundles)
    102 ALL (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, kits, bundles)
    103 NONE (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, kits, bundles)
    1000 ANY (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs)
    1001 EXACT (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs)
    1002 ALL (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs)
    1003 NONE (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs)
    10000 ANY (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs)
    10001 EXACT (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs)
    10002 ALL (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs)
    10003 NONE (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs)
    Note:
    • ANY = combine search keywords with logical OR.
    • ALL = combine search keywords with logical AND.
  2. To change the default search type in the search profile:
    1. Identify the search profile that you want to change the search type value in.
      For example, IBM_findProductsBySearchTerm.
    2. Redefine the search profile in the search configuration file (wc-search.xml) to use the new search type value.
      For example:
      
      <_config:profile name="IBM_findProductsBySearchTerm" indexName="CatalogEntry">
         <_config:query>
            <_config:param name="searchType" value="10002"/>
         </_config:query>
      </_config:profile>
      
      Where the preceding code snippet changes the search type to 10002.
    3. Save your changes and close the file.
    4. Restart the search server.
  3. To override the default search type in the REST request:
    1. Identify the store JSP file where the search REST request is constructed.
      For example, SearchSetup.jspf, CategoryNavigationSetup.jspf, FacetSetup.jspf, SearchContentSetup.jspf, or any other custom JSP files that construct the search REST request.
    2. Locate the following code snippet, where the searchType parameter is set:
      
      <c:set var="searchType" value="${WCParam.searchType}" scope="request"/>
      
    3. Update the search type to the new value.
      For example:
      
      <c:set var="searchType" value="${responseSearchType}" scope="request"/>
         <c:if test="${empty searchType}" >
            <c:set var="searchType" value="${WCParam.searchType}" scope="request"/>
            <c:if test="${empty searchType}" >
      		 		 
               <c:set var="searchType" value="1002" scope="request"/>
            </c:if>
         </c:if>
      
      Where the preceding code snippet changes the search type to 10002.
    4. Save your changes and close the file.