Package org.codelibs.fess.helper
Class SuggestHelper
java.lang.Object
org.codelibs.fess.helper.SuggestHelper
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 Summary
FieldsModifier and TypeFieldDescriptionThe list of content field names.The set of field names for content.protected org.codelibs.fess.mylasta.direction.FessConfigThe Fess configuration for accessing system settings.protected PopularWordHelperThe popular word helper for handling popular words.The set of field names for roles.protected longThe interval for storing search logs.protected org.codelibs.fess.suggest.SuggesterThe suggester instance for handling suggest operations.The set of field names for tags.protected static final StringThe separator for text content. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBadWord(String badWord, boolean apply) Adds a bad word to the suggest index.voidaddElevateWord(String word, String reading, String[] tags, String[] permissions, Float boost, boolean apply) Adds an elevate word to the suggest index.protected voidDeletes all bad words from the suggest index.voiddeleteAllElevateWord(boolean apply) Deletes all elevate words from the suggest index.booleanDeletes all words from the suggest index.voiddeleteBadWord(String badWord) Deletes a bad word from the suggest index.booleanDeletes all document-based words from the suggest index.voiddeleteElevateWord(String word, boolean apply) Deletes a specific elevate word from the suggest index.booleanDeletes all query-based words from the suggest index.longGets the total number of words in the suggest index.longGets the number of words from documents in the suggest index.longGets the number of words from queries in the suggest index.voidindexFromDocuments(Consumer<Boolean> success, Consumer<Throwable> error) Indexes suggest data from documents.voidindexFromSearchLog(List<org.codelibs.fess.opensearch.log.exentity.SearchLog> searchLogList) Indexes suggest data from a list of search logs.voidinit()Initializes the SuggestHelper.voidPurges old suggest data from documents.voidPurges old suggest data from search logs.voidrefresh()Refreshes the suggest index.voidsetSearchStoreInterval(long searchStoreInterval) Sets the interval for storing search logs.voidstoreAllBadWords(boolean apply) Stores all bad words in the suggest index.voidstoreAllElevateWords(boolean apply) Stores all elevate words in the suggest index.voidStores search logs in the suggest index.org.codelibs.fess.suggest.SuggesterGets the suggester instance.
-
Field Details
-
TEXT_SEP
The separator for text content.- See Also:
-
suggester
protected org.codelibs.fess.suggest.Suggester suggesterThe suggester instance for handling suggest operations. -
fessConfig
protected org.codelibs.fess.mylasta.direction.FessConfig fessConfigThe Fess configuration for accessing system settings. -
contentFieldNameSet
The set of field names for content. -
tagFieldNameSet
The set of field names for tags. -
roleFieldNameSet
The set of field names for roles. -
contentFieldList
The list of content field names. -
popularWordHelper
The popular word helper for handling popular words. -
searchStoreInterval
protected long searchStoreIntervalThe 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
Indexes suggest data from documents.- Parameters:
success- A callback for successful indexing.error- A callback for indexing errors.
-
purgeDocumentSuggest
Purges old suggest data from documents.- Parameters:
time- The timestamp to purge data before.
-
purgeSearchlogSuggest
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
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
Adds a bad word to the suggest index.- Parameters:
badWord- The bad word to add.apply- true to apply the changes immediately.
-
deleteBadWord
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.
-