In this lesson, you modify the user data field name mapping to map the profit margin
field to user data using the configuration API. You also create a search profile using the
configuration API.
About this task
To map the user data field and create a profile, use the following Query service API
and a REST client.
Procedure
To customize the user data field name mapping and search configuration to
include custom data, complete the following steps:
-
Modify the user data field name mapping to map the profit margin field to user
data using the configuration API.
-
Restart the Query service
-
From the REST client issue the following command:
POST: http://ElasticSearchServer:30920/search/resources/api/v2/configuration?nodeName=component&envType=auth
Note:
- Use envType as
auth (if using an authoring
environment) or live (if using a
production environment).
- Use basic authentication with the user
name as spiuser and password as
passw0rd for HCL Commerce 9.1.0.0 to 9.1.8.0, or
QxV7uCk6RRiwvPVaa4wdD78jaHi2za8ssjneNMdu3vgqi
for HCL Commerce 9.1.9.0 or greater.
-
For the API body, use the following code:
{
"valuemappingservice": {
"valuemapping": [
{
"internalName": "CatalogEntryUserDataFieldNameMapping",
"externalName": "CatalogEntryUserDataFieldNameMapping",
"valuemap": [
{
"externalValue": "ProfitMargin",
"internalValue": "x_custom.x_profitMargin"
}
]
}
]
}
}
-
Click Send request. The configuration is added
for the component.
-
Restart the Query service.
-
Create a search profile using the configuration API.
-
From the REST client issue the following command:
POST: http://ElasticSearchServer:30920/search/resources/api/v2/documents/profiles/X_findCatalogEntryProfitMargin
Use basic authentication with the user name as
spiuser and password as
passw0rd for HCL Commerce
versions 9.1.0.0 to 9.1.8.0, or
QxV7uCk6RRiwvPVaa4wdD78jaHi2za8ssjneNMdu3vgqi
for HCL Commerce version 9.1.9.0 or greater.
-
For the API body, use the following code:
{
"parentProfileName": "IBM_findProductByIds_Summary",
"profileName": "X_findCatalogEntryProfitMargin",
"query": {
"responseFields": [
"x_custom.x_profitMargin"
]
}
}
-
Click Send request. The search profile is
created successfully.
-
Restart the Query service.
-
Using a REST client, issue the following REST service call to verify
that the profile margin data is returned (using
profileName=
X_findCatalogEntryProfitMargin
).
GET: http://ElasticSearchServer:30920/search/resources/store/1/productview/byIds?id=10766&profileName=X_findCatalogEntryProfitMargin
Use
basic authentication with the user name
spiuser and password
passw0rd for
HCL Commerce versions
9.1.0.0 to 9.1.8.0,
or
QxV7uCk6RRiwvPVaa4wdD78jaHi2za8ssjneNMdu3vgqi for
HCL Commerce version 9.1.9.0 or greater.