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 (EXCLUDE products, kits, bundles, EXCLUDE product level SKUs, product variants, and category level SKUs)
    1 EXACT (EXCLUDE products, kits, bundles, EXCLUDE product level SKUs, product variants, and category level SKUs)
    2 ALL (EXCLUDE products, kits, bundles, EXCLUDE product level SKUs, product variants, and category level SKUs)
    3 NONE (EXCLUDE products, kits, bundles, EXCLUDE product level SKUs, product variants, and category level SKUs)
    10 ANY (INCLUDE products, product variants, kits, bundles, product level SKUs, category level SKUs)
    11 EXACT (INCLUDE products, product variants, kits, bundles, product level SKUs, category level SKUs)
    12 ALL (INCLUDE products, kits, product variants, bundles, product level SKUs, category level SKUs)
    13 NONE (INCLUDE products, product variants, kits, bundles, product level SKUs, category level SKUs)
    100 ANY (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, product variants, kits, bundles)
    101 EXACT (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, product variants, kits, bundles)
    102 ALL (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, product variants, kits, bundles)
    103 NONE (INCLUDE product level SKUs, category level SKUs, EXCLUDE products, product variants, kits, bundles)
    1000 ANY (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs, product variants)
    1001 EXACT (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs, product variants)
    1002 ALL (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs, product variants)
    1003 NONE (INCLUDE products, kits, bundles, category level SKUs, EXCLUDE product level SKUs, product variants)
    HCL Commerce Version 9.1.7.0 or later5000 HCL Commerce Version 9.1.7.0 or laterEXCLUDE ((products) OR (variants AND state:false) If the searchType request parameter is passed in a request parameter, Hero Product Image functionality will be disabled for that request.
    Note: For internal use only.
    10000 ANY (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs, product variants)
    10001 EXACT (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs, product variants)
    10002 ALL (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs, product variants)
    10003 NONE (INCLUDE category level SKUs, EXCLUDE products, kits, bundles, product level SKUs, product variants)
    20000 ANY (INCLUDE variants, kits, bundles, category level SKUs EXCLUDE products, product level SKUs)
    20001 EXACT (INCLUDE variants, kits, bundles, category level SKUs EXCLUDE products, product level SKUs)
    20002 ALL (INCLUDE variants, kits, bundles, category level SKUs EXCLUDE products, product level SKUs)
    20003 NONE (INCLUDE variants, kits, bundles, category level SKUs EXCLUDE products, product level SKUs)
    20010 ANY (INCLUDE products, variants, kits, bundles, category level SKUs EXCLUDE product level SKUs)
    20011 EXACT (INCLUDE products, variants, kits, bundles, category level SKUs EXCLUDE product level SKUs)
    20012 ALL (INCLUDE products, variants, kits, bundles, category level SKUs EXCLUDE product level SKUs)
    20013 NONE (INCLUDE products, variants, kits, bundles, category level SKUs EXCLUDE 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. For more information, see HCL Commerce Search profiles.
    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.
  4. To change the default search type in the search wc-component.xml configuration file:
    1. Edit WCDE_installdir/workspace/search-config-ext/src/runtime/config/com.ibm.commerce.search/wc-component.xml to set the searchType. If the wc-component.xml file does not exist, create one. For example:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <_config:DevelopmentComponentConfiguration
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-component.xsd "
          xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config">
          <_config:valuemappingservice>
          </_config:valuemappingservice>
          <_config:extendedconfiguration>
              <_config:configgrouping name="SearchConfiguration">
                  <_config:property name="searchType" value="20000"/>
              </_config:configgrouping>
          </_config:extendedconfiguration>
      </_config:DevelopmentComponentConfiguration>
    2. Save your changes and close your file, then package and deploy your customization. For more information, see Packaging the customization.
    3. Restart the Search server.
      Note: The search type value in the Search wc-component.xml configuration file is the default search type. If a search profile does not define its own search type within the profile, then it will use the default search type in wc-component.xml. If it has its own search type, then it will overwrite the default search type in wc-component.xml.