Class SuggestServiceProperties

java.lang.Object
de.cxp.ocs.suggest.SuggestServiceProperties
All Implemented Interfaces:
SuggestConfigProvider

public class SuggestServiceProperties extends Object implements SuggestConfigProvider

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 Details

    • SuggestServiceProperties

      public SuggestServiceProperties()
    • SuggestServiceProperties

      public SuggestServiceProperties(Properties properties)
    • SuggestServiceProperties

      public SuggestServiceProperties(@NonNull @NonNull InputStream stream)
  • Method Details

    • getDefaultSuggestConfig

      public SuggestConfig getDefaultSuggestConfig()
    • getConfig

      public SuggestConfig getConfig(String indexName, SuggestConfig modifiableConfig)
      Description copied from interface: SuggestConfigProvider
      Retrieve config for a given index. In case only some index specific values should be set, the default suggest config can be used since it may contain global settings (if not null).
      Specified by:
      getConfig in interface SuggestConfigProvider
      Parameters:
      indexName -
      modifiableConfig - copy of the suggest config that was set as default for the whole service. It can be modified and returned or a different config object can be returned. Returning null is considered equivalent to returning that default config.
      Returns:
    • 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:
    • getManagementPathPrefix

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