HCL Commerce search keyword matching behavior
The Customer submits search trigger matches only on separate words in the customer's search.
For example, if the rule has: contains computer, the following
are the trigger rule evaluation results for different search phrases:
Sample search phrase | Result |
---|---|
Laptop computer | Match |
Computer mouse | Match |
Computers | No match |
The handleNoExactMatchForSearchMarketingSpot() method has been defined in
GetMar-ketingSpotDataCmdImpl that you can override to customize the behavior. Iterate through all
the defined search spots for contains/starts/ends
matches:
/**
* This method returns the e-Marketing Spot object that corresponds to the e-Marketing
* Spot name used in the Get MarketingSpotData request. For search e-Marketing Spots,
* the e-Marketing Spot name is the search term entered by the customer.
* Before this method is called, the entire search term is checked for any defined
* search e-Marketing Spots. If no search e-Marketing Spot is found, then this
* method is called. This method has the following behavior:
* If the customer search term has multiple words, then iterate through each word,
* one at a time, starting with the first word. Check if the individual word has a
* defined search e-Marketing Spot. For each word that has a defined
* search e-Marketing Spot, then the associated search activities will be used.
* For example, there is a search activity defined for the keyword 'computer'.
* The customer is performing a search for 'laptop computer special'.
* <ul>
* <li>First check for search e-Marketing Spot for 'laptop computer special'.</li>
* <li>If none found, first check for search e-Marketing Spot for 'laptop'.</li>
* <li>Next check for search e-Marketing Spot for 'computer'.</li>
* <li>A search e-Marketing Spot is found, so use the search activities associated
* with that e-Marketing Spot.</li>
* <li>Next check for search e-Marketing Spot for 'special'.</li>
* </ul>
* For a customization, you may want to change the behavior so that the match is
* not done on an individual keyword, but instead is on the entire search term. This
* method can be overridden to implement that behavior. In that scenario, the following
* three methods can be used:
* <ul>
* <li><code>MarketingEngineCache.singleton().getSearchEMarketingSpots(Integer storeId)</code>:
* Use this method to get the set of currently defined search e-Marketing Spots. You
* can go through the entire map and find the e-Marketing Spot that matches
* the customer search term according to the custom requirement.</li>
* <li><code>MarketingEngineCache.singleton().getEmarketingSpot(String name, String usage, Integer storeId)</code>:
* Use this method to return the applicable e-Marketing Spot object.</li>
* <li><code>foundMatchForSearchMarketingSpot(eSpot, storeId, pznId)</code>: For each
* search e-Marketing Spot, call this method to call the search activities associated with
* this e-Marketing Spot.
* </ul>
* <p>The following is an example of how to find matches where the desired search term
* (which is stored in the search e-Marketing Spot names)
* can be found anywhere in the customer's search term (which is the emsName parameter
* passed into this method).
* <pre>
CampaignInitiativeCache.CachedEMarketingSpot returnESpot = null;
Integer [] relatedStores = Substitution-Helper.getStorePath(MarketingMetadata.MARKETING_STORE_RELATIONSHIP);
for (int i = 0; i < relatedStores.length; i++) {
Map storeSearchSpots = MarketingEngine-Cache.singleton().getSearchEMarketingSpots(relatedStores[i]);
Iterator storeSearchSpotsIterator = storeSearchSpots.keySet().iterator();
while (storeSearchSpotsIterator.hasNext()) {
String spotName = (String)storeSearchSpotsIterator.next();
if (emsName.contains(spotName)) {
CampaignInitiativeCache.CachedEMarketingSpot eSpot =
MarketingEngine-Cache.singleton().getEmarketingSpot(spotName, usage, relatedStores[i]);
if (eSpot != null) {
// found a partial match spot
foundMatchForSearchMarketingSpot(eSpot, storeId, pznId);
returnESpot = eSpot;
}
}
}
}
return returnESpot;
* </pre>
* @param emsName The name of the e-Marketing Spot in the Get MarketingSpotData request.
* @param usage The usage of the e-Marketing Spot in the Get MarketingSpotData request.
* @param storeId The ID of the store.
* @param pznId The customer's personalization ID.
* @return This method returns the e-Marketing Spot object for which to run the
* search activities. This method may use activities from several search e-Marketing,
* however, only one of the search e-Marketing Spots needs to be returned. If this method
* did not use activities from any search e-Marketing Spots, then null should be returned.
*/
public CachedEMarketingSpot handleNoExactMatchForSearchMarketingSpot(String emsName, String usage, Integer storeId, String pznId)