Package org.codelibs.fess.indexer
Class IndexUpdater
java.lang.Object
java.lang.Thread
org.codelibs.fess.indexer.IndexUpdater
- All Implemented Interfaces:
Runnable
IndexUpdater is responsible for updating the search index with crawled document data.
This class extends Thread and continuously processes access results from the crawler,
transforms them into indexed documents, and updates the OpenSearch index.
The updater performs the following key operations:
- Retrieves crawled documents from the data service
- Transforms document data using appropriate transformers
- Applies document boosting rules and click/favorite count enhancements
- Sends processed documents to the search engine for indexing
- Manages cleanup of processed crawler session data
The updater runs continuously until crawling is finished and all documents are processed. It includes error handling, retry logic, and performance monitoring capabilities.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.codelibs.fess.opensearch.log.exbhv.ClickLogBhvBehavior class for click log operationsprotected org.codelibs.fess.crawler.service.DataService<org.codelibs.fess.crawler.entity.OpenSearchAccessResult> Service for managing crawled document dataprotected longTotal number of processed documentsprotected longTotal execution time in millisecondsprotected org.codelibs.fess.opensearch.log.exbhv.FavoriteLogBhvBehavior class for favorite log operationsprotected booleanFlag indicating if crawling should be finishedList of finished crawler session IDs for cleanupprotected IndexingHelperHelper for document indexing operationsprotected intMaximum number of general errors allowed before terminationprotected intMaximum number of indexer errors allowedprotected SearchEngineClientOpenSearch client for index operationsList of crawler session IDs to processprotected SystemHelperHelper for system-level operationsprotected org.codelibs.fess.crawler.service.UrlFilterServiceService for URL filtering operationsprotected org.codelibs.fess.crawler.service.UrlQueueService<org.codelibs.fess.crawler.entity.OpenSearchUrlQueue> Service for managing URL crawling queueFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddBoostValue(Map<String, Object> map, float documentBoost) Adds a boost value to the document for search relevance scoring.protected voidaddClickCountField(Map<String, Object> doc) Adds a click count field to the document based on search log data.voidAdds a document boost matcher rule for enhancing document relevance scores.protected voidaddFavoriteCountField(Map<String, Object> map) Adds a favorite count field to the document based on user favorite data.voidaddFinishedSessionId(String sessionId) Adds a finished session ID to the cleanup list.voiddestroy()Destroys the IndexUpdater when the container is shutting down.longGets the total number of documents processed.longGets the total execution time for index updates.Gets the list of crawler session IDs being processed.Processes a document through the ingest pipeline if an ingest factory is available.voidinit()Initializes the IndexUpdater after dependency injection.voidrun()Main execution method that runs the index updating process.voidsetCrawlerList(List<org.codelibs.fess.crawler.Crawler> crawlerList) Sets the list of crawler instances that this updater will manage.static voidSets the default uncaught exception handler for all threads.voidsetFinishCrawling(boolean finishCrawling) Sets the flag indicating whether crawling should be finished.voidsetMaxIndexerErrorCount(int maxIndexerErrorCount) Sets the maximum number of indexer errors allowed.voidsetSessionIdList(List<String> sessionIdList) Sets the list of crawler session IDs to process.voidSets the uncaught exception handler for this IndexUpdater thread.protected voidupdateDocument(Map<String, Object> map) Updates a document with additional metadata and enhancements.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
sessionIdList
List of crawler session IDs to process -
searchEngineClient
OpenSearch client for index operations -
dataService
protected org.codelibs.fess.crawler.service.DataService<org.codelibs.fess.crawler.entity.OpenSearchAccessResult> dataServiceService for managing crawled document data -
urlQueueService
protected org.codelibs.fess.crawler.service.UrlQueueService<org.codelibs.fess.crawler.entity.OpenSearchUrlQueue> urlQueueServiceService for managing URL crawling queue -
urlFilterService
protected org.codelibs.fess.crawler.service.UrlFilterService urlFilterServiceService for URL filtering operations -
clickLogBhv
protected org.codelibs.fess.opensearch.log.exbhv.ClickLogBhv clickLogBhvBehavior class for click log operations -
favoriteLogBhv
protected org.codelibs.fess.opensearch.log.exbhv.FavoriteLogBhv favoriteLogBhvBehavior class for favorite log operations -
systemHelper
Helper for system-level operations -
indexingHelper
Helper for document indexing operations -
finishCrawling
protected boolean finishCrawlingFlag indicating if crawling should be finished -
executeTime
protected long executeTimeTotal execution time in milliseconds -
documentSize
protected long documentSizeTotal number of processed documents -
maxIndexerErrorCount
protected int maxIndexerErrorCountMaximum number of indexer errors allowed -
maxErrorCount
protected int maxErrorCountMaximum number of general errors allowed before termination -
finishedSessionIdList
List of finished crawler session IDs for cleanup
-
-
Constructor Details
-
IndexUpdater
public IndexUpdater()Default constructor for IndexUpdater. Initializes a new instance with default settings.
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the IndexUpdater after dependency injection. Sets up the ingest factory if available in the component container. -
destroy
@PreDestroy public void destroy()Destroys the IndexUpdater when the container is shutting down. Stops all crawler instances if crawling is still in progress. -
addFinishedSessionId
Adds a finished session ID to the cleanup list. This method is thread-safe and adds the session ID to be cleaned up later.- Parameters:
sessionId- the crawler session ID that has finished processing
-
run
public void run()Main execution method that runs the index updating process. Continuously processes crawled documents from the data service, transforms them, and updates the search index until crawling is finished and all documents are processed.The method performs the following operations in a loop:
- Retrieves access results from the data service
- Processes each document through transformers
- Applies document boosting and metadata enhancements
- Sends processed documents to the search engine
- Cleans up processed data and manages crawler sessions
The method includes error handling, retry logic, and will terminate if too many empty results are encountered or if a system shutdown is requested.
-
ingest
protected Map<String,Object> ingest(org.codelibs.fess.crawler.entity.AccessResult<String> accessResult, Map<String, Object> map) Processes a document through the ingest pipeline if an ingest factory is available. Applies all configured ingesters to transform and enrich the document data.- Parameters:
accessResult- the access result containing document metadatamap- the document data map to process- Returns:
- the processed document map after applying all ingesters
-
updateDocument
Updates a document with additional metadata and enhancements. Adds click counts, favorite counts, document boosting, and generates document ID. Also applies language-specific updates through the language helper.- Parameters:
map- the document data map to update with additional metadata
-
addBoostValue
Adds a boost value to the document for search relevance scoring. The boost value affects how highly the document will rank in search results.- Parameters:
map- the document data map to add the boost value todocumentBoost- the boost value to apply to the document
-
addClickCountField
Adds a click count field to the document based on search log data. The click count represents how many times users have clicked on this document in search results.- Parameters:
doc- the document data map to add the click count to
-
addFavoriteCountField
Adds a favorite count field to the document based on user favorite data. The favorite count represents how many users have marked this document as a favorite.- Parameters:
map- the document data map to add the favorite count to
-
getExecuteTime
public long getExecuteTime()Gets the total execution time for index updates.- Returns:
- the total execution time in milliseconds
-
getSessionIdList
Gets the list of crawler session IDs being processed.- Returns:
- the list of session IDs
-
setSessionIdList
Sets the list of crawler session IDs to process.- Parameters:
sessionIdList- the list of session IDs to set
-
setFinishCrawling
public void setFinishCrawling(boolean finishCrawling) Sets the flag indicating whether crawling should be finished.- Parameters:
finishCrawling- true if crawling should be finished, false otherwise
-
getDocumentSize
public long getDocumentSize()Gets the total number of documents processed.- Returns:
- the total document count
-
setUncaughtExceptionHandler
Sets the uncaught exception handler for this IndexUpdater thread.- Overrides:
setUncaughtExceptionHandlerin classThread- Parameters:
eh- the uncaught exception handler to set
-
setDefaultUncaughtExceptionHandler
Sets the default uncaught exception handler for all threads.- Parameters:
eh- the default uncaught exception handler to set
-
setMaxIndexerErrorCount
public void setMaxIndexerErrorCount(int maxIndexerErrorCount) Sets the maximum number of indexer errors allowed.- Parameters:
maxIndexerErrorCount- the maximum error count to set
-
addDocBoostMatcher
Adds a document boost matcher rule for enhancing document relevance scores.- Parameters:
rule- the document boost matcher rule to add
-
setCrawlerList
Sets the list of crawler instances that this updater will manage.- Parameters:
crawlerList- the list of crawlers to set
-