Skip to main content

Auto Suggestion in Websphere Commerce Search

There are two types of auto suggestions.. 

1) Suggest keywords based on Search term.
2) Suggest actual Entity based on Search term.

The Auto-Suggestion feature is now handled via Search Rest calls in FEP8. Technically it is Term Search for Spellcheck fields. So the whole thing can be summarized as below mentioned steps:

/conf/solrconfig.xml

  1. Configure request handler for /terms URL
  2. Configure wc_textSuggest and wc_spellCheck configuration
/conf/schema.xml
  1. Define SOLR fields that are too be shown as Auto Suggested keywords when searched for Terms
  2. Define Spell check fields which are to be spell corrected for showing suggestions


SOLR Configuration Changes
 

As auto suggested keywords are nothing but different Terms that are being Indexed at the time of commit, we need to define a handler in solrconfig.xml.

<!--
         WebSphere Commerce terms request handler
         This requestHandler can be used for search term auto-suggest.
-->
<requestHandler name="/terms" class="org.apache.solr.handler.component.SearchHandler">
    <lst name="defaults">
      <bool name="terms">true</bool>
      <str name="terms.fl">spellCheck</str>
      <str name="terms.limit">5</str>
      <str name="terms.mincount">1</str>
      <str name="terms.sort">count</str>
      <bool name="omitHeader">true</bool>
      <bool name="indent">false</bool>
      <str name="wt">json</str>
    </lst>
    <arr name="components">
      <str>wc_termsComponent</str>
    </arr>
</requestHandler>


SOLR Schema Changes


SOLR Field Type Configurations

We need to ensure that required field types are configured in respective schema.xml
  1. wc_textSuggest
  2. spellCorrection
  3. spellCheck
These configuration can be copied from OOTB CatalogEntry/CatalogGroup configuration.

Setup Verification


At this time we can verify if the SOLR cores are setup properly.

Once we have done the configuration, we can see if the designated fields are split properly by hitting /term url as below
http://localhost/solr/MC_10001_Shop_en_US/terms?terms.fl=city&terms.sort=index&terms.limit=15&terms.prefix=chem


terms.fl                     Designated Auto Suggestion type field
terms.limit                  Number of terms to return
terms.prefix                 Initials of search term.

                                         
The final SOLR query looks like as below 

http://localhost/solr/MC_10001_Shop_en_US/terms?qt=%2Fterms&terms.prefix=checm&terms.fl=spellCheck

And the response is :
{
  "terms":{
    "spellCheck":[
      "chemist",5,
      "chemist shop",2,
      "chemist shop new delhi",1,
      "india chemicals",1]}
}

Auto Suggesting Actual Entity

Apart from suggesting Search Keywords, we need to suggest actual Business Entity based on Search terms..This requires utilizing searchProfiles for different cores. For implementation details, refer Respective Core implementation.


Comments

  1. how to avoid comma(,) coming in auto suggest - is there any configurations ?

    ReplyDelete
  2. Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....

    Java training in Bangalore | Java training in Marathahalli

    Java training in Bangalore | Java training in Btm layout

    Java training in Bangalore |Java training in Rajaji nagar

    ReplyDelete
  3. )Deep Learning Projects assist final year students with improving your applied Deep Learning skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include Deep Learning projects for final year into your portfolio, making it simpler to get a vocation, discover cool profession openings,
    Websphere Message Broker Training in Bangalore

    ReplyDelete

Post a Comment

Popular posts from this blog

File Upload in Websphere Commerce

Websphere Commerce has a inbuilt mechanism to handle the file upload process but it has some limitations with it. Whenever a File type is present in request object, commerce ignores the rest of parameters coming after that. The inbuilt mechanism treats the file object as UploadedFile type object. This type of object provides a limited number of options to further process the File Objects. To  overcome these limitation, we need to use Apache Common Fileupload features to handle the File Upload process for Hanes. File Upload Basic Requirements In order to pass a File object in request, we need to make some changes in the Form. File Upload is not supported by REST or Ajax REST Requests. Icon Request Parsing The first step is to parse the request for Uploaded File Objects. And apart from this we need to get the other parameters back to request properties, which is not available because of the limitation of commerce. ...

Websphere Commerce Creating a custom SOLR core

This page describes how we can create custom SOLR cores in commerce. Let's think of a e commerce site where we retailers can log in and can register there shops. We want to index Shops so that user can search for different shops. SOLR Core Naming Convention A custom SOLR core has to be named according to OOTB convention  MC_10001_<coreName>_en_US . The core name should be a single word without any underscores in it. An entry in solr.xml will look like as below < core   instanceDir = "MC_10001\en_US\Shops\"   name = "MC_10001_Shops_en_US"   /> Registering custom core with Search server Create a new folder along with the other SOLR cores,  "Shops " at /search/solr/home/MC_10001/en_US/ Shops  should have a " conf " folder for configuration XMLs . Define SQL in /conf/wc-data-config.xml and map the database fields with SOLR fields. Define SOLR fields in schema.xml We need to register our custom SO...

Enabling Inventory index for storefront in Websphere Commerce

By default, Inventory Index is only meant for business users to use in CMC for Product Ranking and merchandising purpose. This document describes how to enable this OOTB SOLR Index for Store Front usage so that it can be used to get SKUs Inventory from SOLR Index instead of DB hits. The implementation involves two steps: Enable OOTB Inventory Index Make it usable by Store Front Pages Enable Inventory Index This step is well described at Infocenter at  Setting up and building the inventory index Enable Inventory Index for Store Front pages This involves following steps Define a Search resource Handler to accept Inventory fetch requests. SOLR Index Customization, if required Define a search Profile to expose Inventory Schema fields to Response Map SOLR schema fields to External Response fields Custom Expression Provider to get default fulfillment center Id. ...