You can use Index Load to index contract prices from a .CSV file.
Before you begin
- Copy the file
server.config.dir/search/index/indexload/wc-indexload-contractprice.xml
to the development environment project
search-config-ext/src/main/resources/index/indexload.
- Update the following line in the copied Search EAR file
wc-indexload-price.xml file to use your master catalog ID, instead of
10001:
<_config:property name="coreName" value="MC_10001_CatalogEntry_Price_generic" />
Procedure
-
Use SQL to create a Price subcore for the specified master catalogId. For example, if the
masterCatalogId is 10001, the following SQL command will create Price subcore.
Insert into srchconfext(srchconfext_id,indextype,indexscope,indexsubtype)
values(select max(srchconfext) 1 from srchconfext, "CatalogEntry","10001","Price");
-
Restart the HCL Commerce Search server.
-
When the Search server starts, a price subcore will be created in the
solrhome/MC_mastercatalogId/generic/CatalogEntry/Price
directory. For our example master catalogId, the core name will be
MC_10001_CatalogEntry_Price_generic. This core name will be used later when
composing the Index Load configuration file.
-
You need two Index Load configuration files to load the price profile.
- server.config.dir/resources/search/index/indexload/wc-indexload-externalprice-demo.xml
- As well as specifying performance tuning parameters, this file specifies the configuration file
that Index Load will use. It also contains the target core name and the datasource .CSV file.
<_config:LoadItem name="ExternalPrice-1" fileName="wc-indexload-externalprice-csv.xml">
<_config:property name="coreName" value="MC_10001_CatalogEntry_Price_generic" />
<_config:property name="groupName" value="1" />
<_config:DataSourceLocation location="resources/search/index/indexload/contract-price-example1.csv" />
</_config:LoadItem>
- server.config.dir/resources/search/index/indexload/wc-indexload-externalprice-csv.xml
- This file specifies the CSV mediator. The CSV mediator will be used to transform between the
field in the CSV file and the fields of the Solr
field.SearchIndexLoadCSVMediator. The mediator is defined as follows.
</_config:BusinessObjectBuilder>
<_config:BusinessObjectMediator className="com.ibm.commerce.foundation.internal.server.services.indexload.mediator.SolrIndexLoadBusinessObjectMediator"/>
<_config:BusinessObjectMediator className="com.ibm.commerce.search.indexload.mediator.SearchIndexLoadCSVMediator" />
-
Use the Index Load service to load the inventory core with the configuration files.
https://localhost:3738/search/admin/resources/indexload/profile/externalprice-demo/start
Note: To change the default settings, you need to edit the file under
/search-config-ext/src/main/resources/index/indexload/ and go through the WCB
and CI/CD process to deploy the new configuration file to its container.
Once the Index Load
run completes, it will return one of the following
results:
Code 0: IndexLoad completed successfully with no errors.
Code 1: IndexLoad was successful with errors within the specified tolerance for each load item.
Code 2: IndexLoad was not successful. The maximum tolerance level for errors was reached for at least one of the configured load items.
Code 3: IndexLoad was not successful. An unrecoverable error has occurred.
Code -1: IndexLoad was running.
Results
You can check the status of the command with the following call:
https://localhost:3738/search/admin/resources/indexload/profile/externalprice-demo/status
The core can be called with the
query:http://localhost:3737/solr/MC_10001_CatalogEntry_Price_generic/select?q=*:*