Changing properties in the HCL Commerce Search configuration file (wc-search.xml)

To change the value of an existing property in the HCL Commerce Search configuration file (wc-search.xml), you must create a customized version of the file in a new folder. The customized version of the file must contain only the changed properties.

Before you begin

To understand the properties that this file contains, see the HCL Commerce Search configuration file (wc-search.xml) topic.

About this task

In your custom wc-search.xml file, change the <_config:profile> node type.
Note: To add or remove a configuration within an existing search profile, add a new profile in your custom wc-search.xml file that extends the existing profile you want to modify.

The following procedure can be used to change (rather than add or remove) a value of an existing property within a search profile, which is defined in the wc-search.xml file.

Procedure

  1. Open HCL Commerce Developer and switch to the Enterprise Explorer view.
  2. Create a custom HCL Commerce Search configuration file (wc-search.xml) if one does not exist:
    1. Go to the following path: workspace_dir\search-config-ext\src\runtime\config
    2. In the config directory, go to the com.ibm.commerce.search directory. If this directory contains a custom version of the wc-search.xml file, then open the file and skip to Step 4.
    3. Create an empty wc-search.xml file in the com.ibm.commerce.search directory. This file is your custom wc-search.xml file.
  3. Add the basic XML elements in your custom wc-search.xml file:
    1. Open your empty custom wc-search.xml file in an XML editor.
    2. Copy the following code into the file:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <_config:search-config
      	xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-search.xsd ">
      
      	<_config:server name="BasicConfiguration">
      		<_config:embedded />
      	</_config:server>
      
      </_config:search-config>
  4. Edit the Search configuration file.
    1. Edit the HCL Commerce Search configuration file Search_home\resources\search\runtime\config\com.ibm.commerce.search\wc-search.xml.

      Never change properties directly in this file because your changes will be overwritten with future IBM software updates.

    2. Copy the XML elements for the properties you want to change from the default HCL Commerce search configuration file to your custom wc-search.xml file. Insert the copied XML elements above the </_config:search-config> element.

      Even though you are copying only certain elements, you must maintain the XML hierarchy for those elements in the file. For example, to change the property that is defined in a specific <_config:param> element, retain the parent and ancestor elements of the <_config:param> element, but delete all the siblings. You must also maintain the ordering of the siblings, as they are expected in the same order that they appear in the default configuration file. For an example, see Example 1: Changing properties in the custom wc-search.xml file.

    3. Change the values for the copied properties.
    4. Preceding the </_config:search-config> element, add a list of the profiles that inherit directly or indirectly from the profile for which you changed property values.

      Search profiles have a hierarchical structure. The default wc-search.xml file contains a number of profiles that inherit elements directly and indirectly from other profiles. For example, the IBM_Global profile has a number of profiles that inherit from it. To ensure that the values you change are picked up by the extended profiles, you must include a list of these profiles in your custom wc_search.xml file. By including this list, the property values you change are properly merged between the two files. For an example, see Example 1: Changing properties in the custom wc-search.xml file.

  5. Save and close your custom wc-search.xml file.
  6. Test your configuration changes.

Example 1: Changing properties in the custom wc-search.xml file

The following example shows the contents of a custom wc-search.xml file that changes three properties that are defined within the IBM_Global profile:

<?xml version="1.0" encoding="UTF-8"?>
<_config:search-config
	xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-search.xsd ">

	<_config:server name="BasicConfiguration">
		<_config:embedded />
	</_config:server>

A
    <_config:profile name="IBM_findWebContentsBySearchTerm" indexName="UnstructuredContent"> 
       <_config:query> 
              <_config:param name="maxRows" value="50"/> 
       </_config:query> 
       <_config:spellcheck> 
              <_config:param name="limit" value="3"/> 
       </_config:spellcheck>
    </_config:profile>
B
</_config:search-config>
In the previous example, the code snippet that starts with A and ending with B is the inserted code that changes three properties:
  • maxRows: The property value is changed from 100 to 50.
  • limit: The property value is changed from 5 to 3.
Notice that the parent and ancestor elements of each <_config:param> element are retained in the custom wc-search.xml file.

You can define a new custom search profile to meet your business needs. The custom search profile can be modeled off an existing profile and can include both default and custom implementations. A common scenario where you might define custom profiles is when none of the default profiles meet your business needs. Or, when you want certain logic to run before other logic. For example, by defining a new custom provider which must run before any of the default providers or processors.

The new search profile must comply to the wc-search.xml file XML schema definition. The advantage of defining a new profile is that you have full control over how the profile is designed. However, if the profile is meant to be used by an external REST resource method, you must map it to a REST resource method in the wc-rest-resourceconfig.xml file.

Before you create a custom search profile, review the wc-search.xml XML schema definition file configuration orders and supported child elements. Review the WebSphere Commerce search profiles and identify the REST service to map to your custom search profile. Use its default search profile as a reference when designing your new search profile:
  1. In your extended wc-search.xml file, define the config:profile opening and closing elements, with the mandatory name and indexName attributes. For example:
    <_config:profile name="X_findProductsBySearchTerm" indexName="CatalogEntry">
    </_config:profile
  2. Add the different required configurations such, as query, facet, and result. For example:
    <_config:profile name="X_findProductsBySearchTerm" indexName="CatalogEntry">
    <_config:query>
    List of all parameters, providers, fields, preprocessors, and post processors in their expected order
    </_config:query>
    <_config:result>
    List all of the result fields
    </_config:result>
    </_config:profile>
  3. Register the new custom search profile in the workspace_dir\search-config-ext\src\runtime\config\com.ibm.commerce.rest\wc-rest-resourceconfig.xml file.