Package org.codelibs.fess.helper
Class CrawlingInfoHelper
java.lang.Object
org.codelibs.fess.helper.CrawlingInfoHelper
Helper class for managing crawling information and statistics.
Provides functionality to track crawling sessions, manage document expiration,
and handle crawling information storage and retrieval.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgenerateId(String urlId) Generates a hashed ID from the provided URL ID string.generateId(Map<String, Object> dataMap) Generates a unique document ID from the provided data map.getCanonicalSessionId(String sessionId) Extracts the canonical session ID by removing any suffix after the first hyphen.protected CrawlingInfoServiceRetrieves the CrawlingInfoService component instance.getDocumentExpires(org.codelibs.fess.opensearch.config.exentity.CrawlingConfig config) Calculates the document expiration date based on crawling configuration.protected longgetExpiredTime(int days) Calculates the expiration time in milliseconds from the current time.getInfoMap(String sessionId) Retrieves all crawling information parameters for the specified session as a map.getSessionIdList(SearchEngineClient searchEngineClient) Retrieves a list of session IDs with their document counts from the search engine.voidputToInfoMap(String key, String value) Adds a key-value pair to the information map.voidsetMaxSessionIdsInList(int maxSessionIdsInList) Sets the maximum number of session IDs to include in session ID lists.voidStores crawling information and parameters for the specified session.voidupdateParams(String sessionId, String name, int dayForCleanup) Updates crawling information parameters for the specified session.
-
Field Details
-
FACET_COUNT_KEY
Key used for facet count aggregations.- See Also:
-
infoMap
Map containing crawling information parameters. -
documentExpires
Document expiration time in milliseconds. -
maxSessionIdsInList
protected int maxSessionIdsInListMaximum number of session IDs to include in lists.
-
-
Constructor Details
-
CrawlingInfoHelper
public CrawlingInfoHelper()Creates a new instance of CrawlingInfoHelper.
-
-
Method Details
-
getCrawlingInfoService
Retrieves the CrawlingInfoService component instance.- Returns:
- the CrawlingInfoService component for managing crawling information
-
getCanonicalSessionId
Extracts the canonical session ID by removing any suffix after the first hyphen. If the session ID contains a hyphen, returns the portion before the first hyphen. Otherwise, returns the original session ID.- Parameters:
sessionId- the session ID to process- Returns:
- the canonical session ID (portion before first hyphen, or original if no hyphen)
-
store
Stores crawling information and parameters for the specified session. Creates a new crawling info record if none exists or if create flag is true. Also stores any accumulated information parameters and clears the info map.- Parameters:
sessionId- the session ID for the crawling informationcreate- if true, creates a new crawling info regardless of existing records- Throws:
FessSystemException- if unable to store the crawling session
-
putToInfoMap
Adds a key-value pair to the information map. Initializes the info map as a synchronized LinkedHashMap if it doesn't exist.- Parameters:
key- the parameter key to storevalue- the parameter value to store
-
updateParams
Updates crawling information parameters for the specified session. Sets the name and expiration time based on the provided parameters.- Parameters:
sessionId- the session ID to updatename- the name to set for the crawling session (uses system name if blank)dayForCleanup- number of days until cleanup (sets expiration if >= 0)- Throws:
FessSystemException- if unable to store the updated crawling session
-
getDocumentExpires
Calculates the document expiration date based on crawling configuration. If the config has a timeToLive value, calculates expiration from current time. Otherwise, returns the stored document expiration time.- Parameters:
config- the crawling configuration containing time-to-live settings- Returns:
- the document expiration date, or null if no expiration is set
-
getExpiredTime
protected long getExpiredTime(int days) Calculates the expiration time in milliseconds from the current time.- Parameters:
days- the number of days from now when the item should expire- Returns:
- the expiration time in milliseconds since epoch
-
getInfoMap
Retrieves all crawling information parameters for the specified session as a map.- Parameters:
sessionId- the session ID to retrieve parameters for- Returns:
- a map containing all key-value parameter pairs for the session
-
generateId
Generates a unique document ID from the provided data map. Constructs an ID string from URL, roles, and virtual hosts, then generates a hash.- Parameters:
dataMap- the document data map containing URL, roles, and virtual host information- Returns:
- a unique hashed ID string for the document
-
getSessionIdList
Retrieves a list of session IDs with their document counts from the search engine. Uses aggregation to get session segments and their corresponding document counts.- Parameters:
searchEngineClient- the search engine client to perform the query- Returns:
- a list of maps containing session IDs and their document counts
-
generateId
Generates a hashed ID from the provided URL ID string. Encodes special characters using URL encoding or Base64 encoding as needed, then applies a message digest algorithm to create a unique hash.- Parameters:
urlId- the URL ID string to generate a hash for- Returns:
- a hashed ID string generated from the input URL ID
-
setMaxSessionIdsInList
public void setMaxSessionIdsInList(int maxSessionIdsInList) Sets the maximum number of session IDs to include in session ID lists. This controls the size limit for aggregation results when retrieving session lists.- Parameters:
maxSessionIdsInList- the maximum number of session IDs to include in lists
-