Unstructured content in the storefront

Searching for unstructured content requires two queries since unstructured content is indexed in a different core. One query gets the related IDs by searching the unstructure field of the structured content, while the other query searches the unstructured index using the keywords and generated IDs scope from the first search.

Two queries are used because the result list must contain information from both the structured content index and the unstructured content index. Since both of the results have their own sorting and paging parameters, they are arranged in the following order:
  1. Structured content search results.
  2. Unstructured content search results.
The search process invokes the SolrJ API to post the query string to the request handler. There are two invocations involved:
  • The first query posts keyword and search scopes to the product index core, to retrieve the catalog entry ID list. The search scope additionally includes the unstructure field.
  • The second query posts keyword and the return ID list of the first query to the unstructured content index core, to retrieve the highlighted result, and catalog entry ID.

Search results displayed in the storefront

The following enablement steps display product attachment search result in the storefront:
  1. Register the expression builder for the new search request. For example:
    
    <expression-builder>
    		<name>getCatalogNavigationAttachmentView</name>
    		<data-type-name>CatalogNavigationView</data-type-name>
    		<expression-template>{_wcf.ap='$accessProfile$';_wcf.search.profile='$searchProfile$';_wcf.search.term='$searchTerm$';_wcf.search.type='$searchType$';_wcf.search.exclude.term='$filterTerm$';_wcf.search.exclude.type='$filterType$';_wcf.search.manufacturer='$manufacturer$';_wcf.search.price.minimum='$minPrice$';_wcf.search.price.maximum='$maxPrice$';_wcf.search.facet='$facet$';_wcf.search.sort='$orderBy$';_wcf.search.meta='$metaData$'}/CatalogNavigationView</expression-template>
    		<param>
    			<name>accessProfile</name>
    			<value>IBM_Store_CatalogEntrySearch</value>
    		</param>
    		<param>
    			<name>searchType</name>
    			<value>0</value>
    		</param>
    		<param>
    			<name>searchProfile</name>
    			<value>IBM_findCatalogEntryByUnstructureField</value>
    		</param>
    	</expression-builder>
    
  2. In the storefront JSP file, point the expressionBuilder parameter to the newly created expression builder. For example:
    
    <wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogNavigationViewType" var="catalogNavigationView" 
    	expressionBuilder="getCatalogNavigationAttachmentView" scope="request" varShowVerb="showCatalogNavigationView" 
    	maxItems="${pageSize}" recordSetStartNumber="${WCParam.beginIndex}" scope="request">
    <wcf:param name="searchProfile" value="${searchProfile}" />
    	<wcf:param name="searchTerm" value="${WCParam.searchTerm}" />
    	<wcf:param name="searchType" value="${searchType}" />
    	<wcf:param name="metaData" value="${WCParam.metaData}" />
    	<wcf:param name="orderBy" value="${WCParam.orderBy}" />
    	<wcf:param name="facet" value="${WCParam.facet}" />
    	<wcf:param name="filterTerm" value="${WCParam.filterTerm}" />
    	<wcf:param name="filterType" value="${WCParam.filterType}" />
    	<wcf:param name="manufacturer" value="${WCParam.manufacturer}" />
    	<wcf:param name="minPrice" value="${WCParam.minPrice}" />
    	<wcf:param name="maxPrice" value="${WCParam.maxPrice}" />
    	<wcf:contextData name="storeId" data="${WCParam.storeId}" />
    </wcf:getData>
    
  3. In the store page, parse the returned BOD and extract the related attachment information for showing it on the page. For example:
    
    <c:forEach var="attachment" items="${catEntry.attachments}" varStatus="att_status">
    <c:set var="attachmentName" value="${attachment.metaData['name']}" />
    <c:set var="attachmentPath" value="${attachment.attachmentAssetPath}" />
    <c:set var="attachmentID" value="${attachment.attachmentAssetID}" />
    <c:set var="attachmentImage" value="${attachment.metaData['image']}" />
    <a  href="${storeImgDir}${attachmentPath}" id="WC_CatalogEntryDBThumbnailDisplayJSPF_<c:out value='${attachmentID}'/>_attachment_links_11" class="h_tnav_but">
    	<img src="${jspStoreImgDir}${attachmentImage}" alt="" align="left"/>
    	<c:out value="${attachmentName}" escapeXml="false"/>
    </a>
    </c:forEach>