Class TypeAheadSuggestionConfiguration


  • public class TypeAheadSuggestionConfiguration
    extends Object
    Represents a suggestion to be returned in a TypeAheadResponse.

    For example, let's assume that in addition to text prediction, we want to return a set of the top 5 products with their name and price that relate to the suggestion terms.

    A (shortened) configuration might look as follows:

     {
      "name": "products",
             "suggestionFields": [
                 {
                     "fieldDefinition": {
                         "id": "nameField",
                         "label": "Name",
                         "indexableType": "PRODUCT",
                         "abbreviation": "name"
                         },
                     "variantType": "TEXT"
                 },
                 {
                     "fieldDefinition": {
                         "id": "priceField",
                         "label": "Price",
                         "indexableType": "PRODUCT",
                         "abbreviation": "price"
                         },
                     "variantType": "DOUBLE"
                 }]
             "showResultCount": false,
             "faceted": false,
             "resultLimit": 5
         }
     
    When doing a query for "iPhone", for instance, we would get back a result for a product in the following form, with up to 5 matching products:
     "products": [
         {
             "price": 619.0,
             "name": "iPhone 8 64GB (Silver)"
         }]
     
    • Constructor Detail

      • TypeAheadSuggestionConfiguration

        public TypeAheadSuggestionConfiguration()
    • Method Detail

      • getName

        public String getName()
        The name to be displayed in the results. For instance, "Products". This may also be a translatable key.
        Returns:
        The name to be displayed in the results
      • getSuggestionFields

        public List<SuggestionField> getSuggestionFields()
        The list of fields to be returned with this suggestion.
        Returns:
        The list of fields to be returned with this suggestion
      • isFaceted

        public boolean isFaceted()
        Is this configuration faceted? Required for showing a result count.

        Note that when a result is faceted, it can only be faceted on a single SuggestionField.

        Returns:
        Is this configuration faceted?
      • getResultLimit

        public int getResultLimit()
        The maximum number of results to return for this configuration.
        Returns:
        The maximum number of results to return
      • setName

        public void setName​(String name)
        The name to be displayed in the results. For instance, "Products". This may also be a translatable key.
        Parameters:
        name - The name to be displayed in the results
      • setSuggestionFields

        public void setSuggestionFields​(List<SuggestionField> suggestionFields)
        The list of fields to be returned with this suggestion.
        Parameters:
        suggestionFields - The list of fields to be returned with this suggestion
      • setFaceted

        public void setFaceted​(boolean faceted)
        Is this configuration faceted? Required for showing a result count.

        Note that when a result is faceted, it can only be faceted on a single SuggestionField.

        Parameters:
        faceted - Is this configuration faceted?
      • setResultLimit

        public void setResultLimit​(int resultLimit)
        The maximum number of results to return for this configuration.
        Parameters:
        resultLimit - The maximum number of results to return
      • canEqual

        protected boolean canEqual​(Object other)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object