Package org.codelibs.fess.rank.fusion
Class RankFusionProcessor
java.lang.Object
org.codelibs.fess.rank.fusion.RankFusionProcessor
- All Implemented Interfaces:
AutoCloseable
RankFusionProcessor manages multiple search engines and combines their results using rank fusion algorithms.
This processor supports searching with multiple searchers concurrently and merging their results based on
ranking scores to provide more comprehensive and accurate search results.
The processor maintains a pool of searchers and an executor service for concurrent operations.
It implements rank fusion techniques to combine results from different search engines
and provides a unified search interface.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classWrapper class for SearchRequestParams that allows overriding specific parameters. -
Field Summary
FieldsModifier and TypeFieldDescriptionSet of available searcher names that can be used for search processingprotected ExecutorServiceExecutor service for concurrent search operations across multiple searchersprotected final List<RankFusionSearcher> Thread-safe list of rank fusion searchers available for processing search requestsprotected intSize of the window for rank fusion processing, determines how many results to consider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected QueryResponseListcreateResponseList(List<Map<String, Object>> documentList, long allRecordCount, String allRecordCountRelation, long queryTime, boolean partialResults, FacetResponse facetResponse, int start, int pageSize, int offset) Creates a QueryResponseList containing the search results and metadata.extractList(List<Map<String, Object>> docs, int pageSize, int startPosition) Extracts a subset of documents from the full result list based on pagination parameters.protected RankFusionSearcher[]Gets the array of available searchers based on configuration.voidinit()Initializes the rank fusion processor after construction.protected voidload()Loads the available searcher names from system properties.voidregister(RankFusionSearcher searcher) Registers a new searcher with the rank fusion processor.search(String query, SearchRequestParams params, org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> userBean) Performs a search operation using rank fusion across available searchers.searchWithMainSearcher(RankFusionSearcher searcher, String query, SearchRequestParams params, org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> userBean) Performs a search using only the main searcher without rank fusion.searchWithMultipleSearchers(RankFusionSearcher[] searchers, String query, SearchRequestParams params, org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> userBean) Performs concurrent searches using multiple searchers and fuses the results.voidsetSearcher(RankFusionSearcher searcher) Sets the main searcher at index 0 of the searchers list.protected floatConverts an object value to a float for score calculations.voidupdate()Updates the processor configuration by reloading available searchers.
-
Field Details
-
searchers
Thread-safe list of rank fusion searchers available for processing search requests -
executorService
Executor service for concurrent search operations across multiple searchers -
windowSize
protected int windowSizeSize of the window for rank fusion processing, determines how many results to consider -
availableSearcherNameSet
Set of available searcher names that can be used for search processing
-
-
Constructor Details
-
RankFusionProcessor
public RankFusionProcessor()Default constructor for RankFusionProcessor. Initializes the processor with default values. The actual initialization is performed by the init() method which is called after construction.
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the rank fusion processor after construction. Sets up the window size based on configuration and loads available searchers. This method is called automatically after the bean is constructed. -
update
public void update()Updates the processor configuration by reloading available searchers. This method executes the load operation asynchronously in a separate thread. -
load
protected void load()Loads the available searcher names from system properties. Parses the "rank.fusion.searchers" system property to determine which searchers are available for use in rank fusion processing. -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
search
public List<Map<String,Object>> search(String query, SearchRequestParams params, org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> userBean) Performs a search operation using rank fusion across available searchers. If only one searcher is available, uses the main searcher. Otherwise, performs concurrent searches across multiple searchers and fuses the results.- Parameters:
query- the search query stringparams- search request parameters including pagination and filtersuserBean- optional user information for personalized search- Returns:
- list of search result documents with fused ranking scores
-
getAvailableSearchers
Gets the array of available searchers based on configuration. Filters the searchers list to include only those specified in the available searcher name set. If no specific searchers are configured, returns all searchers.- Returns:
- array of available RankFusionSearcher instances
-
searchWithMultipleSearchers
protected List<Map<String,Object>> searchWithMultipleSearchers(RankFusionSearcher[] searchers, String query, SearchRequestParams params, org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> userBean) Performs concurrent searches using multiple searchers and fuses the results. Executes searches in parallel across all provided searchers, then combines the results using rank fusion algorithms to produce a unified result set.- Parameters:
searchers- array of searchers to use for concurrent searchingquery- the search query stringparams- search request parameters including pagination and filtersuserBean- optional user information for personalized search- Returns:
- list of search result documents with fused ranking scores
-
extractList
protected List<Map<String,Object>> extractList(List<Map<String, Object>> docs, int pageSize, int startPosition) Extracts a subset of documents from the full result list based on pagination parameters. Applies proper bounds checking to ensure the extracted range is within the document list size.- Parameters:
docs- the full list of search result documentspageSize- the number of documents to include in the pagestartPosition- the starting position for pagination- Returns:
- sublist of documents for the requested page
-
searchWithMainSearcher
protected List<Map<String,Object>> searchWithMainSearcher(RankFusionSearcher searcher, String query, SearchRequestParams params, org.dbflute.optional.OptionalThing<org.codelibs.fess.mylasta.action.FessUserBean> userBean) Performs a search using only the main searcher without rank fusion. This method is used when only one searcher is available or configured.- Parameters:
searcher- the main searcher to use for the search operationquery- the search query stringparams- search request parameters including pagination and filtersuserBean- optional user information for personalized search- Returns:
- list of search result documents from the main searcher
-
createResponseList
protected QueryResponseList createResponseList(List<Map<String, Object>> documentList, long allRecordCount, String allRecordCountRelation, long queryTime, boolean partialResults, FacetResponse facetResponse, int start, int pageSize, int offset) Creates a QueryResponseList containing the search results and metadata. Wraps the document list with additional information about the search operation including record counts, timing, and pagination details.- Parameters:
documentList- the list of search result documentsallRecordCount- the total number of records foundallRecordCountRelation- the relationship of the record count (exact, approximate, etc.)queryTime- the time taken to execute the search querypartialResults- whether the results are partial due to timeout or other constraintsfacetResponse- the facet information for the search resultsstart- the starting position for paginationpageSize- the size of the current pageoffset- the offset applied to the results- Returns:
- QueryResponseList containing the search results and metadata
-
toFloat
Converts an object value to a float for score calculations. Handles Float and String types, returning 0.0f for unsupported types.- Parameters:
value- the object to convert to float- Returns:
- float representation of the value, or 0.0f if conversion fails
-
setSearcher
Sets the main searcher at index 0 of the searchers list. This method is used to configure the primary searcher for rank fusion processing. If searchers list is empty, adds the searcher; otherwise, replaces the first searcher.- Parameters:
searcher- the RankFusionSearcher to set as the main searcher
-
register
Registers a new searcher with the rank fusion processor. Adds the searcher to the searchers list and initializes the executor service if it hasn't been created yet. The executor service is created with a thread pool sized based on configuration or system capabilities.- Parameters:
searcher- the RankFusionSearcher to register
-