Class SuggestConfig

java.lang.Object
de.cxp.ocs.smartsuggest.spi.SuggestConfig
All Implemented Interfaces:
Cloneable

public class SuggestConfig extends Object implements Cloneable
  • Field Details

    • locale

      public Locale locale
    • alwaysDoFuzzy

      public boolean alwaysDoFuzzy
    • useDataSourceMerger

      public boolean useDataSourceMerger
    • groupKey

      public String groupKey
    • groupDeduplicationOrder

      public Optional<String[]> groupDeduplicationOrder
    • useRelativeShareLimit

      public boolean useRelativeShareLimit
    • prefetchLimitFactor

      public int prefetchLimitFactor
    • maxSharpenedQueries

      public int maxSharpenedQueries
    • groupConfig

      public List<SuggestConfig.GroupConfig> groupConfig
    • isIndexConcurrently

      public boolean isIndexConcurrently
  • Constructor Details

    • SuggestConfig

      public SuggestConfig()
  • Method Details

    • setLocale

      public void setLocale(Locale locale)
      Set locale for string transformation and sorting.
      Parameters:
      locale - locale
    • setUseDataSourceMerger

      public void setUseDataSourceMerger(boolean useDataSourceMerge)

      If several suggest-data-providers are used, they are indexed into separate indexes by default. This option activates a merging logic, so that all provided data is merged into one index.

      This could reduce load and improve performance since a single Lucene suggester is asked for results. However in such a case the weights should be in a similar range to avoid a proper ranking.

      Default: false
      Parameters:
      useDataSourceMerge -
    • setAlwaysDoFuzzy

      public void setAlwaysDoFuzzy(boolean alwaysDoFuzzy)
      By default fuzzy searches are only done, if there are no exact matches within primary or secondary text. If this flag is set, fuzzy search is also done if result size is below limit.
      Parameters:
      alwaysDoFuzzy - true to activate
    • setSortOrder

      public void setSortOrder(SuggestConfig.SortStrategy sortStrategy)
      Defines how matching suggest terms are ordered in the result.
      Parameters:
      sortStrategy - sortStrategy
    • setGroupKey

      public void setGroupKey(String groupKey)

      In case several data-sources are used, each data-source is requested for the same amount of suggestions. Per default all those suggestions are simply appended and truncated to get the final list of suggestions.

      With this setting it is possible to specify a key that is available in the payload of all provided suggestions. The final result list will then be grouped by this payload-value and truncated according to the provided group configs.

      It's recommended to setGroupConfig as well, otherwise the default limiter will be used after grouping.

      Parameters:
      groupKey - groupKey
    • addGroupConfig

      public void addGroupConfig(String groupName, int limit)

      Add a group config with the specified name and limit to the end of the ordered list.

      Use the groupName CommonPayloadFields.PAYLOAD_TYPE_OTHER = 'other' to specify a default limit value.

      Parameters:
      groupName - groupName
      limit - limit
    • setGroupDeduplicationOrder

      public void setGroupDeduplicationOrder(String[] groupDeduplicationOrder)

      Defines in which order similar suggestions from different "groups" are preferred. Names that appear first are preferred over names appearing later.

      This setting is 'null' per default, which means no deduplication is done at all. If an empty String[] is set, deduplication is done randomly.

      This only works, if the suggest service is configured with a grouping key.

      Parameters:
      groupDeduplicationOrder - ordered array, suggest entries from groups at beginning are preferred
    • setUseRelativeShareLimit

      public void setUseRelativeShareLimit(boolean useRelativeShareLimit)
      Defines to use the limits of the group-configs as relative share values, e.g. 20 and 80 as 20% and 80%.

      This only works, if the suggest service is configured with a grouping key.

      Parameters:
      useRelativeShareLimit - set to true to activate relative share
    • setGroupConfig

      public void setGroupConfig(List<SuggestConfig.GroupConfig> groupConfig)
      Defines in which order the suggestion groups should be returned and how they should be limited.
      • If 'useRelativeShareLimit' is 'false', these limits are considered absolute.
      • If 'useRelativeShareLimit' is 'true', the limits are normalized into according relative values, e.g. 1, 2 and 2 becomes 20%, 40% and 40%

      This only works, if the suggest service is configured with a grouping key.

      Parameters:
      groupConfig - full groupConfig
    • setMaxSharpenedQueries

      public void setMaxSharpenedQueries(int maxSharpenedQueries)
      Defines the limit of returned sharpened queries.

      Sharpened queries are queries that are injected directly (without requesting a Lucene index) from a hash-map if the input query matches one of the existing entries.

      This limit only is considered if there are more sharpened queries than defined by that limit.

      Parameters:
      maxSharpenedQueries -
    • setPrefetchLimitFactor

      public void setPrefetchLimitFactor(int prefetchLimitFactor)

      If grouping and limiting is configured by a key that comes from a single or merged data-provider, then this value can be used to increase the internal amount of fetched suggestions. This is usable to increase the likeliness to get the desired group counts.

      Default: 1
    • isIndexConcurrently

      public boolean isIndexConcurrently()
      If set to false, the indexation of the received data will be done sequentially. This means it will take longer until the service is ready for usage and will spare computational power that might be used for others.
      Returns:
    • clone

      public SuggestConfig clone()
      Overrides:
      clone in class Object