Change properties in the WebSphere Commerce Search configuration file (wc-search.xml)

To change the value of an existing property in the WebSphere Commerce Search configuration file (wc-search.xml), we 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 beginning

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


Task info

In our 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 our custom wc-search.xml file that extends the existing profile we 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 WebSphere Commerce Developer and switch to the Enterprise Explorer view.

  2. Create a custom WebSphere 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 our custom wc-search.xml file.

  3. Add the basic XML elements in our 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 WebSphere 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 our changes will be overwritten with future IBM software updates.

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

      Even though we are copying only certain elements, we 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. We 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 we 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, we must include a list of these profiles in our 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 our custom wc-search.xml file.

  6. Test the 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:

In the previous example, the code snippet that starts with A and ending with B is the inserted code that changes three properties:

Notice that the parent and ancestor elements of each <_config:param> element are retained in the custom wc-search.xml file.

We 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 we might define custom profiles is when none of the default profiles meet your business needs. Or, when we 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, we must map it to a REST resource method in the wc-rest-resourceconfig.xml file. Before creating 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 our custom search profile. Use its default search profile as a reference when designing your new search profile:

  1. In our 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.