Skip to main content

Websphere Commerce SOLR REST Framework

With new feature pack FEP8, data can be directly fetched from SOLR index via REST calls without hitting commerce server. In order to do the customization, we first need to understand the REST framework in Websphere commerce.


  • Every REST call has a unique pattern like /productview/byCatentryId/{catentryId}
  • To handle such REST request, the entry points are Rest Handlers.
  • In this case, it's ProductViewHandler.
  • These REST handlers are of AbstractSearchResourceHandler type and are annotated with different Path annotations.
  • These annotation could be at two level, class level and method level.
  • In general, /productview/ represents a class level path and the next token represents different methods.

@Path ("store/{storeId}/productview")
public class ProductViewHandler extends AbstractSearchResourceHandler {

   @Path ("byCatentryId/{catentryId}")
   public Response getProductByUniqueID(@QueryParam String responseFormat...) {
   }

   @Path ("byPartNumber/{partnumber}")

   public Response getProductByPartNumber(@QueryParam String responseFormat...) {
   }
}

  • The method name and class name has no significance but just conventions associated with them. The actual mapping is determined by the Path annotation.
  • Now, how would Search server know that there exists a Handler with ability to handle specific patterns?
  • Every REST handler is supposed to be registered with Search server. OOTB handlers are defined in /Search-Rest/WebContent/WEB-INF/config/resources-search.properties
  • If you want to create your custom REST handlers, an entry needs to be defined in /Search-Rest/WebContent/WEB-INF/config/resources-search-ext.properties.
  • At server startup time, the entries in resource file are loaded and different Path annotations are registered with search server.

Comments

Popular posts from this blog

Websphere Commerce "too many boolean clauses" problem

Sometimes in large scale applications, Store encountered error message is shown on Product Listing page. Root cause: On PLP, sometimes we need to show some information which can be derived from associate SKUs, like color swatches etc. While getting these information from Index, SOLR needs to build the query with product SKU information. When a product is too many SKUs, the parsing fails and we do see error message like below: SolrCore      E org.apache.solr.common.SolrException log org.apache.solr.common.SolrException: org.apache.lucene.queryParser.ParseException: Cannot parse 'catentry_id:(87765 "87766" "87767" "87768" ... ...)':  too many boolean clauses Solution: SOLR has a default maxBoolean configuration which is 3072. Look for the < maxBooleanClauses >  attribute in solrconfig.xml and increase it to appropriate value to handle your catalog structure.

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...

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 Configure request handler for  /terms  URL Configure  wc_textSuggest  and  wc_spellCheck  configuration /conf/schema.xml Define SOLR fields that are too be shown as Auto Suggested keywords when searched for Terms 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 han...