Package de.cxp.ocs

Class SuggestProperties


  • public class SuggestProperties
    extends Object

    A configuration wrapper around all required settings. All settings can be configured as environment variables or system properties. System properties are always preferred over environment variables.

    Only the environment variable names are documented - the System Properties are the same, just in the lowercase form and with dots instead underscores (e.g. instead 'SUGGEST_SERVER_PORT' it is 'suggest.server.port').

    • Constructor Detail

      • SuggestProperties

        public SuggestProperties​(Optional<InputStream> customProperties)
        using system properties as backing properties
    • Method Detail

      • getServerPort

        public int getServerPort()
        Expects env var 'SUGGEST_SERVER_PORT' set to a valid port number. Defaults to 8081.
        Returns:
      • getServerAdress

        public String getServerAdress()
        Expects env var 'SUGGEST_SERVER_ADDRESS' set to a valid server address. Defaults to "0.0.0.0".
        Returns:
      • getUpdateRateInSeconds

        public int getUpdateRateInSeconds()

        Expects env var 'SUGGEST_UPDATE_RATE' set to an integer between 5 and 3600. It's used as the interval on how often the SuggestDataProviders are asked if they have new data.

        search-test-ocssuggest-6b65dd5598-jz7z5

        Defaults to 60.

        Returns:
      • getPreloadIndexes

        public String[] getPreloadIndexes()
        Expects the env var SUGGEST_PRELOAD_INDEXES as a comma separated list of all index names that should be initialized and loaded on startup.
        Returns:
      • getIndexFolder

        public Path getIndexFolder()

        Expects the env var 'SUGGEST_INDEX_FOLDER' to name a index-folder that should be used for lucene to store its data.

        Defaults to a temporary directory with the prefix "ocs_suggest".

        Returns:
      • getSuggesterMaxIdleMinutes

        public int getSuggesterMaxIdleMinutes()

        Expects the env var 'SUGGESTER_MAX_IDLE_MINUTES' or the system property 'suggester.max.idle.minutes' to be set to an integer value. Defaults to 30.

        It's used to close suggesters if unused for that specified time. In case a request comes in for that suggester again, it is initialized asynchronously. This means it will be available after a few seconds (depending on the backing suggest-data-providers) after the first request.

        Returns:
      • getGroupKey

        public Optional<String> getGroupKey()

        Expects the env var 'SUGGEST_GROUP_KEY' to be set to a string value. If set, it will be used to extract that particular payload value and group the suggestions accordingly.

        It's recommended to specify 'SUGGEST_GROUP_SHARE_CONF' or 'SUGGEST_GROUP_CUTOFF_CONF' as well, otherwise the default limiter will be used after grouping.

        Returns:
        grouping key
      • getGroupedShareConf

        public Optional<LinkedHashMap<String,​Double>> getGroupedShareConf()

        Expects the env var 'SUGGEST_GROUP_SHARE_CONF' in the format 'group1=0.x,group2=0.x' to be used as group-share configuration for the ConfigurableShareLimiter.

        This limiter is only used, if 'SUGGEST_GROUP_KEY' is defined as well. But this limiter is prefered over 'GroupedCutOffLimiter' (in case both configurations exist).

        Returns:
      • getGroupedCutoffConf

        public Optional<LinkedHashMap<String,​Integer>> getGroupedCutoffConf()

        Expects the env var 'SUGGEST_GROUP_CUTOFF_CONF' to be specified in the format 'group1=N,group2=M'. Also requires 'SUGGEST_GROUP_KEY' to be set.

        If specified, the GroupedCutOffLimiter will be configured with this cut-off limits (but not if 'SUGGEST_GROUP_SHARE_CONF' is defined as well).

        Returns:
        cut-off limits configuration for GroupedCutOffLimiter
      • getGroupedCutoffDefaultSize

        public Integer getGroupedCutoffDefaultSize()

        Expects the env var 'SUGGEST_GROUP_CUTOFF_DEFAULT' to be set to an integer value.

        Only retrieved, if 'SUGGEST_GROUP_KEY' is set and 'SUGGEST_GROUP_SHARE_CONF' does not exist. It's used as the default limit for the GroupedCutOffLimiter.

        Defaults to 5.

        Returns:
        default limit for GroupedCutOffLimiter
      • getGroupDeduplicationOrder

        public Optional<String[]> getGroupDeduplicationOrder()
        If property is set, the returned values will be deduplicated. As a value a comma separated list of the group-values can be specified. It's used as a priority order: suggestions of the groups defined first will be preferred over suggestions from other groups. Example: a value "brand,keyword" will be used to remove a keyword suggestions if there is a similar brand suggestions. Comparison is done on normalized values (lowercase+trim). Defining the property without a value will enable deduplication, but will do that without any priorization.
        Returns:
      • getManagementPathPrefix

        public String getManagementPathPrefix()
        Prefix for /health and /metrics path. Should start with a slash and end without. Defaults to empty string.
        Returns: