com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr

Interface NavigationSuggestion

  • All Known Implementing Classes:
    AbstractNavigationSuggestion, BrandNavigationSuggestion, CategoryNavigationSuggestion, WebContentNavigationSuggestion


    public interface NavigationSuggestion

    All Navigation suggestions implement this interface. Navigation suggestions are automatically displayed when shoppers type search terms in the search box on the store front. Suggestions are also grouped into categories.

    For example:

    • Products
    • Categories
    • Brands
    • Articles
    There should be one implementation of this interface for each navigation suggestion category.

    Classes should extend com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.AbstractNavigationSuggestion and implement this interface.

    The search framework calls the com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter which calls the populateSuggestion method of each NavigationSuggestion defined in the wc-search.xml file.

    Each implementation class has access to custom properties that can be defined through configuration in the wc-search.xml file. They can be accessed via the getProperties() method. The superclass AbstractNavigationSuggestion sets the properties read from the configuration file into the map. See the description of 'profile -> navigationSuggestion -> param' in the wc-search.xml below for an example.

    The list of navigation suggestions are configured in the wc-search.xml file. The search profile named IBM_findNavigationSuggestions is invoked by the store front to get the suggestions. If you wish to add additional NavigationSuggestions, extend this search profile.

    IBM Internal:
    Each one of these implementations must be configured under this search profile, IBM_findNavigationSuggestions, for it to be invoked. (com.ibm.commerce.catalog-fep/wc-search.xml)

    Customers:
    Customers must extend this search profile to add their own suggestion handlers. All of the content should be copied from the profile 'IBM_findNavigationSuggestions' and placed in their extension profile (com.ibm.commerce.catalog-ext/wc-search.xml)


    Search configuration wc-search.xml snippet:
      
    <_config:profile indexName="CatalogEntry" name="x_IBM_findNavigationSuggestions" extends="IBM_findNavigationSuggestions">
          <_config:query>
              <_config:param name="debug" value="false"/>
              <_config:param name="maxRows" value="50"/>
              <_config:param name="maxTimeAllowed" value="5000"/>
              <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchProfileNameValidator"/>
              <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchIndexNameValidator"/>
              <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchNoSearchResultsExpressionProvider"/>
              <_config:provider classname="com.ibm.commerce.catalog.facade.server.services.search.expression.solr.SolrSearchExpressionValidator"/>
          </_config:query>
          <_config:result>
              <_config:filter classname="com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter"/>
          </_config:result>
          <_config:navigationSuggestion>
          	<_config:suggestion name="Brand"
          			handler="com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.BrandNavigationSuggestion">
          	</_config:suggestion>
          	<_config:suggestion name="Category"
          			handler="com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.CategoryNavigationSuggestion">
          	</_config:suggestion>
          	<_config:suggestion name="Articles"
          			handler="com.ibm.commerce.catalog.facade.server.services.search.suggestion.solr.WebContentNavigationSuggestion">
          		<_config:param name="totalNumber" value="100"/>
          	</_config:suggestion>
          	<_config:suggestion name="MyCustomNavigationSuggestion"
          			handler="com.mycompany.search.suggestion.solr.MyNavigationSuggestion">
          		<_config:param name="myCustomProperty" value="1000"/>
          	</_config:suggestion>
          </_config:navigationSuggestion>
      </_config:profile>
       

    In the search profile, the following information is required:

    • profile -> result -> filter -> classname="com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter":

      This classname 'com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter' is required and looks for registered navigation suggestion handlers associated with the search profile and call the populateSuggestion(...) method for each handler to populate their suggestion.


    • profile -> navigationSuggestion -> suggestion -> handler:

      This handler attribute defines which implementation populates the suggestion information.

    In the search profile, the following information is optional:

    • profile -> navigationSuggestion -> suggestion -> name:

      This name attribute should be used as an identifier for a suggestion category. This can used to help ordering in the storefront JSP.

      The search results filter class com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrSearchNavigationSuggestionsResultFilter will instantiate a suggestionView for you, set the identifier, if the name attribute is defined in the wc-search.xml configuration and will pass it to populateSuggestion method of your NavigationSuggestion. ie. suggestionView.setIdentifier(handlerName);
    • profile -> navigationSuggestion -> suggestion -> param

      This node allows for custom name value pairs to be accessed and used for customization. The name-value pairs defined in this section is available to the developer in a map. ie. <_config:param name="myCustomProperty" value="1000"/> The key in the properties map is 'myCustomProperty' and the value is '1000'.

    See Also:
    SearchNavigationSuggestionsResultFilter, AbstractNavigationSuggestion, BrandNavigationSuggestion, CategoryNavigationSuggestion, WebContentNavigationSuggestion, getProperties(), setProperties(Map), populateSuggestion(String, SuggestionViewType)
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright notice field.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      java.util.Map getProperties()
      This method returns the set of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.
      void populateSuggestion(java.lang.String profile, com.ibm.commerce.catalog.facade.datatypes.SuggestionViewType suggestionCategory)
      This method populates a single navigation suggestion category for use in the storefront.
      void setProperties(java.util.Map properties)
      This method sets the list of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.
    • Field Detail

      • COPYRIGHT

        static final java.lang.String COPYRIGHT
        IBM Copyright notice field.
        See Also:
        Constant Field Values
    • Method Detail

      • populateSuggestion

        void populateSuggestion(java.lang.String profile,
                                com.ibm.commerce.catalog.facade.datatypes.SuggestionViewType suggestionCategory)

        This method populates a single navigation suggestion category for use in the storefront.

        This method should return all possible values for this navigation suggestion category. (ie. All brands, categories, articles that will be used to aid navigation in the store)

        The object suggestionCategory must be populated with your suggestion category information for your navigation suggestion to be displayed on the storefront.

        In the storefront, the service is called to return all possible values for each navigation suggestion category. The storefront performs the filtering of the values as the customer types into the quick search box.

        Modifications to the storefront JSPs are required. See the information center for more information describing the storefront JSPs modifications.

        The JSPs requiring modification are:

        • CachedHeaderDisplay.jsp
        • CachedSuggestions.jsp
        • SearchSetup.jspf

        This method will need to fetch all values for this NavigationSugesstion category from a data source (typically the database or the search engine) and mediate this data into the suggestionCategory (com.ibm.commerce.catalog.facade.datatypes.SuggestionViewType) and its corresponding entries, (com.ibm.commerce.catalog.facade.datatypes.SuggestionEntryViewType).

        The following is a description of the SuggestionViewType and SuggestionEntryViewType objects that must be populated:

        The xml data structure looks like this:

        
            <_cat:SuggestionView>
              <_cat:Identifier>Brand</_cat:Identifier>
              <_cat:Label>Brand</_cat:Label>
              <_cat:Entry>
                <_cat:Name>MapleWear</_cat:Name>
                <_cat:Value>mfName_ntk_cs</_cat:Value>
                <_cat:Image>MapleWear</_cat:Image>
                <_cat:UserData>
                	<_wcf:UserDataField name="Count">418</_wcf:UserDataField>
                </_cat:UserData>
              </_cat:Entry>
              <_cat:Entry>
                <_cat:Name>Sharpson</_cat:Name>
                <_cat:Value>mfName_ntk_cs</_cat:Value>
                <_cat:Image>Sharpson</_cat:Image>
                <_cat:UserData>
                	<_wcf:UserDataField name="Count">20</_wcf:UserDataField>
                </_cat:UserData>
              </_cat:Entry>
            </_cat:SuggestionView>
         


        • SuggestionView -> Identifier:

          This is the identifier for this navigation suggestion category. It is pre-populated with the value specified in the wc-search.xml file for the handler name.
          (wc-search.xml: profile -> navigationSuggestion -> name)

        • SuggestionView -> Label:

          This is a language sensitive display name for this suggestion. It is displayed in the drop-down menu in the storefront as a suggestion category name. (ie. 'Brand' or 'Category' or 'Support')

          To determine the language to populate, the business context can be checked for the language in the current service request.
          ie. Integer iLangId = CatalogComponentHelper.getLanguageId();
        • SuggestionView -> Entry -> Name:

          This is a language sensitive display name for this suggestion entry. This area should be populated with a value for a value for a suggestion. (ie. 'Nike' or 'Adidas' or 'Puma')

          To determine the language to populate, the business context can be checked for the language in the current service request.
          ie. Integer iLangId = CatalogComponentHelper.getLanguageId();
        • SuggestionView -> Entry -> Value:

          This is the value for use with link building in the store. You should populate this area with values that help the store developer build a url for the desired behaviour when a customer clicks on one of your suggestion entries.

        • SuggestionView -> Entry -> Image:

          This is the path to a display image for this suggestion entry. Out of the box, the storefront JSP does not use this property.

        • SuggestionView -> Entry -> UserData -> UserDataField:

          This is a an area to put name-value pairs with custom data. The key and value in the map are under your control.

        The following is an example of how to create navigation suggestion entries (SuggestionEntryViewType) and populate them.

          // Get the list of suggestion entries
          List  suggestionEntries = suggestionCategory.getEntry();
          
          ...
          // Set the label
          suggestionCategory.setLabel(label);
          ...
          
          // Create and populate the entries
                SuggestionEntryViewType suggestionEntry = CatalogFactory.eINSTANCE.createSuggestionEntryViewType();
                com.ibm.commerce.foundation.common.datatypes.UserDataType userData = suggestionEntry.getUserData();
                if(userData==null) {
                  userData = CommerceFoundationFactory.eINSTANCE.createUserDataType();
                }
                suggestionEntry.setUserData(userData);
                // Populate suggestion entry
                // Name
                suggestionEntry.setName("My suggestion name");
                // Value
                suggestionEntry.setValue("My suggestion value to help the store developer build a URL for when a customer clicks on my suggestion");
                // Image
                suggestionEntry.setImage("My suggestion image");
                // User data
                Map userDataFields = userData.getUserDataField();
                userDataFields.put("myCustomProperty", "myCustomValue");
         
         
          // Finally, add this entry to the list of entries
                suggestionEntries.add(suggestionEntry);
         

        Parameters:
        profile - The search profile name.
        suggestionCategory - An instantiated SuggestionViewType object. You must populate this object with your suggestions. If this navigation suggestion handler was configured with a name, the identifier is pre-populated in the SuggestionViewType object.
        See Also:
        SuggestionViewType, SuggestionEntryViewType, AbstractNavigationSuggestion.populateSuggestion(String, SuggestionViewType)
      • getProperties

        java.util.Map getProperties()

        This method returns the set of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.

        ie. <_config:param name="myCustomProperty" value="1000"/> The key in the properties map is 'myCustomProperty' and the value is '1000'.

        Returns:
        Map The set of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.
        See Also:
        AbstractNavigationSuggestion.getProperties()
      • setProperties

        void setProperties(java.util.Map properties)

        This method sets the list of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.

        ie. <_config:param name="myCustomProperty" value="1000"/> The key in the properties map is 'myCustomProperty' and the value is '1000'.

        Parameters:
        properties - The set of customizable properties that were defined as name-value pairs in the search configuration for a navigation suggestion handler.
        See Also:
        AbstractNavigationSuggestion.setProperties(Map)