Change 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 used for multiple keyword search terms such as the AND operator, OR operator, and exact match.


Task info

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:


Procedure

  1. Determine which search type we want to set using the following table as a reference:

    Option Description
    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 to change the search type value in. For example, IBM_findProductsBySearchTerm. See
      WebSphere 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. See Changing properties in the WebSphere Commerce Search configuration file (wc-search.xml).

    3. Save our 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 our 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 our changes and close your file, then package and deploy our customization. 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.