Configuring Query xC custom extension

The /configuration endpoint is used to add the customized configuration details in ZooKeeper node. There is a root node in ZooKeeper with the name /configuration, and inside the root node are child nodes where you can add the configuration.

The available nodes are:
  1. xC cextensions
  2. wc-component
  3. Colors, organized by language
  4. Filters to aid in natural language processing
  5. Units of measure, and
  6. Relevancy

To register xC customizations for pre- and post-processing of the actual search request to this child node, pass the configuration node the nodeName="xC" parameter as a request.

For example,
http://data_environment_hostname:30921/search/resources/api/v2/configuration?nodeName=xC&envType=auth
For the full REST API specification, see the Query REST API.

Example

Here is an example structure for an xC configuration:
{
    "preProcess": [
        {
        	"storeId" : "1",
            "endpoint": {
                "query": "/productview/bySearchTerm/pre",
                "xC": "/commerceue/extension/search/productview/preBySearchTerm",
                "properties": [
                    {}
                ]
            }
        }
    ],
    "postProcess": [
        {
        	"storeId" : "1",
            "endpoint": {
                "query": "/productview/bySearchTerm/post",
                "xC": "/commerceue/extension/search/productview/postBySearchTerm",
                "properties": [
                    {
                        "fields": [
                            "name",
                            "shortDescription",
                            "UserData"
                        ]
                    }
                ]
            }
        }
    ]
}
You can use Java, as in the following CustomProductViewResource.java file:
package com.hcl.commerce.search.rest;

/*
 * Licensed Materials - Property of HCL Technologies Limited. (C) Copyright HCL Technologies Limited 1996, 2020.
 */

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/productview")
public class CustomProductViewResource {

	/**
	 * This method is use to add the search criteria.
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping(value = "/preBySearchTerm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity preFindProductsBySearchTerm(@RequestBody Map criteria) throws Exception {

		ArrayList list = (ArrayList) criteria.get("content");

		List filter = new ArrayList();
		filter.add("manufacturer.text:\"manufacturerName\"");

		Map filterMap = new HashMap();
		filterMap.put("_wcf.search.internal.filterquery", filter);
		list.add(filterMap);
		criteria.put("content", list);
		ResponseEntity result = new ResponseEntity(criteria, HttpStatus.OK);

		return result;
	}


	/**
	 * This method is use to manipulate the data post from server.
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping(value = "/postBySearchTerm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity postFindProductsBySearchTerm(@RequestBody Map response) throws Exception {

		ArrayList list = (ArrayList) response.get("content");
		for (Object obj : list) {
			if (obj instanceof Map) {
				Map m = (Map) obj;
				m.put("name", "Custom :: " + m.get("name"));
			}
		}
		ResponseEntity result = new ResponseEntity(response, HttpStatus.OK);

		return result;
	}
}

Managing Configuration and Components

HCL Commerce Search supports managing various configurations such as ingest-config, Component, and STA using a flexible REST API. These configurations are used to customize and control different aspects of search behavior per environment.
/search/resources/api/v2/configuration?nodeName={nodeName}&envType={envType}&locale={locale}
Supported HTTP Methods:
  • POST - Add a new configuration.
  • PATCH - Update or append configurations.
  • PUT - Move configurations from the "auth" node to the "live" node.
  • GET - Retrieve existing configurations.
  1. Use the POST method to create a new configuration from scratch.
  2. Use the PATCH method to modify or append values.
    Note: Do not use POST to update configurations, as it will overwrite existing configurations entirely.
  3. Use the PUT method to move configuration resources from the authoring (auth) environment to the live environment.