Class RelatedQueryHelper

java.lang.Object
org.codelibs.fess.helper.AbstractConfigHelper
org.codelibs.fess.helper.RelatedQueryHelper

public class RelatedQueryHelper extends AbstractConfigHelper
Helper class for managing related query configurations. This class provides functionality to load, cache, and retrieve related queries based on search terms and virtual hosts. Related queries are used to suggest alternative or supplementary search terms to improve search results.
  • Field Details

    • relatedQueryMap

      protected volatile Map<String,Map<String,String[]>> relatedQueryMap
      Map storing related queries organized by virtual host key and search term. The outer map key is the virtual host key, the inner map key is the search term (in lowercase), and the value is an array of related query strings.
  • Constructor Details

    • RelatedQueryHelper

      public RelatedQueryHelper()
      Default constructor for RelatedQueryHelper. Initializes the helper with an empty related query map.
  • Method Details

    • init

      @PostConstruct public void init()
      Initializes the RelatedQueryHelper after dependency injection is complete. This method is called automatically by the dependency injection framework and loads the initial related query configurations.
    • getAvailableRelatedQueryList

      public List<org.codelibs.fess.opensearch.config.exentity.RelatedQuery> getAvailableRelatedQueryList()
      Retrieves a list of all available related query entities from the data store. The results are ordered by term and limited by the configured maximum fetch size.
      Returns:
      a list of RelatedQuery entities containing all available related queries
    • load

      public int load()
      Description copied from class: AbstractConfigHelper
      Load the configuration.
      Specified by:
      load in class AbstractConfigHelper
      Returns:
      The number of loaded configurations.
    • getHostKey

      protected String getHostKey(org.codelibs.fess.opensearch.config.exentity.RelatedQuery entity)
      Extracts the virtual host key from a RelatedQuery entity. If the virtual host is blank or null, returns an empty string.
      Parameters:
      entity - the RelatedQuery entity to extract the host key from
      Returns:
      the virtual host key, or empty string if blank or null
    • getRelatedQueries

      public String[] getRelatedQueries(String query)
      Retrieves related queries for a given search term. The search is performed using the current virtual host context and the query term is converted to lowercase for case-insensitive matching.
      Parameters:
      query - the search term to find related queries for
      Returns:
      an array of related query strings, or empty array if none found