Class SuggestHelper

java.lang.Object
org.codelibs.fess.helper.SuggestHelper

public class SuggestHelper extends Object
Helper class for managing the suggest feature. This class provides methods for initializing the suggester, indexing data from various sources, and managing elevate words and bad words.
  • Field Details

    • TEXT_SEP

      protected static final String TEXT_SEP
      The separator for text content.
      See Also:
    • suggester

      protected org.codelibs.fess.suggest.Suggester suggester
      The suggester instance for handling suggest operations.
    • fessConfig

      protected org.codelibs.fess.mylasta.direction.FessConfig fessConfig
      The Fess configuration for accessing system settings.
    • contentFieldNameSet

      protected final Set<String> contentFieldNameSet
      The set of field names for content.
    • tagFieldNameSet

      protected final Set<String> tagFieldNameSet
      The set of field names for tags.
    • roleFieldNameSet

      protected final Set<String> roleFieldNameSet
      The set of field names for roles.
    • contentFieldList

      protected List<String> contentFieldList
      The list of content field names.
    • popularWordHelper

      protected PopularWordHelper popularWordHelper
      The popular word helper for handling popular words.
    • searchStoreInterval

      protected long searchStoreInterval
      The interval for storing search logs.
  • Constructor Details

    • SuggestHelper

      public SuggestHelper()
      Constructs a new suggest helper.
  • Method Details

    • init

      @PostConstruct public void init()
      Initializes the SuggestHelper. This method sets up the suggester, configures field names, and initializes the connection to the search engine.
    • suggester

      public org.codelibs.fess.suggest.Suggester suggester()
      Gets the suggester instance.
      Returns:
      The suggester instance.
    • storeSearchLog

      public void storeSearchLog()
      Stores search logs in the suggest index.
    • indexFromSearchLog

      public void indexFromSearchLog(List<org.codelibs.fess.opensearch.log.exentity.SearchLog> searchLogList)
      Indexes suggest data from a list of search logs.
      Parameters:
      searchLogList - The list of search logs to index.
    • indexFromDocuments

      public void indexFromDocuments(Consumer<Boolean> success, Consumer<Throwable> error)
      Indexes suggest data from documents.
      Parameters:
      success - A callback for successful indexing.
      error - A callback for indexing errors.
    • purgeDocumentSuggest

      public void purgeDocumentSuggest(LocalDateTime time)
      Purges old suggest data from documents.
      Parameters:
      time - The timestamp to purge data before.
    • purgeSearchlogSuggest

      public void purgeSearchlogSuggest(LocalDateTime time)
      Purges old suggest data from search logs.
      Parameters:
      time - The timestamp to purge data before.
    • getAllWordsNum

      public long getAllWordsNum()
      Gets the total number of words in the suggest index.
      Returns:
      The total number of words.
    • getDocumentWordsNum

      public long getDocumentWordsNum()
      Gets the number of words from documents in the suggest index.
      Returns:
      The number of document words.
    • getQueryWordsNum

      public long getQueryWordsNum()
      Gets the number of words from queries in the suggest index.
      Returns:
      The number of query words.
    • deleteAllWords

      public boolean deleteAllWords()
      Deletes all words from the suggest index.
      Returns:
      true if the operation was successful, false otherwise.
    • deleteDocumentWords

      public boolean deleteDocumentWords()
      Deletes all document-based words from the suggest index.
      Returns:
      true if the operation was successful, false otherwise.
    • deleteQueryWords

      public boolean deleteQueryWords()
      Deletes all query-based words from the suggest index.
      Returns:
      true if the operation was successful, false otherwise.
    • storeAllElevateWords

      public void storeAllElevateWords(boolean apply)
      Stores all elevate words in the suggest index.
      Parameters:
      apply - true to apply the changes immediately.
    • deleteAllElevateWord

      public void deleteAllElevateWord(boolean apply)
      Deletes all elevate words from the suggest index.
      Parameters:
      apply - true to apply the changes immediately.
    • deleteElevateWord

      public void deleteElevateWord(String word, boolean apply)
      Deletes a specific elevate word from the suggest index.
      Parameters:
      word - The elevate word to delete.
      apply - true to apply the changes immediately.
    • addElevateWord

      public void addElevateWord(String word, String reading, String[] tags, String[] permissions, Float boost, boolean apply)
      Adds an elevate word to the suggest index.
      Parameters:
      word - The elevate word.
      reading - The reading of the word.
      tags - The tags associated with the word.
      permissions - The permissions for the word.
      boost - The boost value for the word.
      apply - true to apply the changes immediately.
    • deleteAllBadWords

      protected void deleteAllBadWords()
      Deletes all bad words from the suggest index.
    • storeAllBadWords

      public void storeAllBadWords(boolean apply)
      Stores all bad words in the suggest index.
      Parameters:
      apply - true to apply the changes immediately.
    • addBadWord

      public void addBadWord(String badWord, boolean apply)
      Adds a bad word to the suggest index.
      Parameters:
      badWord - The bad word to add.
      apply - true to apply the changes immediately.
    • deleteBadWord

      public void deleteBadWord(String badWord)
      Deletes a bad word from the suggest index.
      Parameters:
      badWord - The bad word to delete.
    • refresh

      public void refresh()
      Refreshes the suggest index.
    • setSearchStoreInterval

      public void setSearchStoreInterval(long searchStoreInterval)
      Sets the interval for storing search logs.
      Parameters:
      searchStoreInterval - The search store interval in minutes.