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
About this task
<_config:profile>
node type.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
- Open HCL Commerce Developer and switch to the Enterprise Explorer view.
-
Create a custom HCL Commerce Search configuration file
(wc-search.xml) if one does not exist:
- Go to the following path: workspace_dir\search-config-ext\src\runtime\config
- 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.
- Create an empty wc-search.xml file in the com.ibm.commerce.search directory. This file is your custom wc-search.xml file.
-
Add the basic XML elements in your custom wc-search.xml file:
-
Edit the Search configuration file.
- Save and close your custom wc-search.xml file.
- 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>
-
maxRows
: The property value is changed from100
to50
. limit
: The property value is changed from5
to3
.
<_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.
- 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
- 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>
- 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.