Partial part number search plugin

The part number search is based on the pattern matching for the part number. This is done by adding part number patterns in the wc-component.json file with PartNumberPatterns property and configuring SearchNLPPartNumberProviderHelper in the NLP profile for PartNumber. But this approach only works for patterns defined and does not support the partial search.

Use the custom part number search plugin SearchNLPCustomPartNumberHelper to get the part number search working without using a pattern and to add support for partial part number search. The class name SearchNLPPartNumberProviderHelper in the NLP profile has to be changed to SearchNLPCustomPartNumberHelper in order to activate the custom plugin. The new fields used for pattern search in the custom plugin are default.sku.normalized and default.mpn.normalized. Data in these fields is populated at index time, and it also gets normalised (removing all the special characters) with the es_pattern_replace normalizer. Custom plugin first looks up the input search term in the index field configured in the wc-component.json file PatternSearch property. If the search word matches a part number or a partial part number and there are any special characters in the search term, all of the special characters will be removed.

  1. To enable partial part number search, override the HCL_NLPProfile to make use of custom part number search plugin.
    • Replace PartNumber class name from SearchNLPPartNumberProviderHelper to SearchNLPCustomPartNumberHelper in the NLP profile.
    • The following profile can be used to configure the NLP profile.
      http://<dataQueryHost>:<dataQueryPort>/search/resources/api/v2/documents/profiles/HCL_NLPProfile?profileType=NLP
  2. Partial search is disabled by default for part number searches. The PatternSearch attribute in the wc-component.json/ component ZooKeeper node has to be updated in order to be enabled.
    The default for pattern search is exact match for the following four criteria. Each type of pattern is defined as follows.
    • Exact Match [term]#default.sku.normalized~10,default.mpn.normalized~5
    • Starts with [term]*#default.sku.normalized~10,default.mpn.normalized~5
    • Ends with *[term]#default.sku.normalized~10,default.mpn.normalized~5
    • Contains *[term]*#default.sku.normalized~10,default.mpn.normalized~5
    Patterns include two parts:
    • Pattern, example; [term]
    • Comma separated field name, with boost value separated by ~.
  3. Calling the configuration endpoint with the following request will allow you to query the data for supported patterns and make changes to the field names and boost values.
    PATCH/ POST -- http://<dataqueryhost>:<port>/search/resources/api/v2/configuration?nodeName=component&envType=auth
    {
    	"extendedconfiguration": {
    		"configgrouping": [
    			{
    			"name": "SearchConfiguration",
    				"property": [
    				{
    				"name": "PatternSearch",
    				"value": "*[term]*#default.sku.normalized~10,default.mpn.normalized~5"
    				}
    			]
    		}
    	]
                   }
    }
    

    A list of special characters has been added to the pattern_replace_char_filter char filter in the product index settings. With the es_pattern_replace normalizer, this char filter will delete any special characters from the field value map at index time. The query service will apply the same pattern to remove special characters from terms if a patch is applied to the pattern search.

    To add a new character, the Pattern can be changed in the Product Index Settings. With the help of the configuration endpoint, the query service pattern may be altered.

    The PatternSearchSpecialCharacters property has the list of all special characters [!@%&*()_+=#$,.|<>?/{}\\[\\]-] in the wc-component.jsonfile.

  4. The product index of type keyword with the normalizer : es_pattern_replace must have that field accessible in order to create a new field with boost value for pattern search. The field value's special characters will all be eliminated by this normalizer. Then, using the configuration endpoint and the information from step 3 you can configure the new field in the query service.
Note:
  • If a new field is being added to the index, reindexing is required.
  • Use the POST request method if this is your first time adding a configuration using the configuration endpoint; otherwise, use the PATCH request method when running the configuration endpoint.
  • After the above configuration change, restart the query service.