Package org.codelibs.fess.query
Class QueryProcessor
java.lang.Object
org.codelibs.fess.query.QueryProcessor
Query processor component that handles query filters and commands.
This class provides a pipeline for processing Lucene queries by applying
a chain of filters and executing registered query commands.
The processor maintains a map of query commands indexed by query class names and a list of filters that are applied in order during query processing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for query processing filters.static interfaceInterface for filter chains that process queries through a sequence of filters. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected QueryProcessor.FilterChainThe filter chain that processes queries through all registered filters before executing the appropriate query command.protected List<QueryProcessor.Filter> List of filters that will be applied during query processing.protected Map<String, QueryCommand> Map of query commands indexed by query class simple names. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(String name, QueryCommand queryCommand) Adds a query command to the processor.voidaddFilter(QueryProcessor.Filter filter) Adds a filter to the processing pipeline.protected QueryProcessor.FilterChainappendFilterChain(QueryProcessor.Filter filter, QueryProcessor.FilterChain chain) Appends a filter to an existing filter chain.protected QueryProcessor.FilterChainCreates the default filter chain that executes query commands.protected voidCreates the filter chain from the registered filters.org.opensearch.index.query.QueryBuilderexecute(QueryContext context, org.apache.lucene.search.Query query, float boost) Executes query processing through the filter chain.voidinit()Initializes the query processor after construction.
-
Field Details
-
queryCommandMap
Map of query commands indexed by query class simple names. Used to lookup appropriate command handlers for different query types. -
filterList
List of filters that will be applied during query processing. Filters are applied in the order they are added to this list. -
filterChain
The filter chain that processes queries through all registered filters before executing the appropriate query command.
-
-
Constructor Details
-
QueryProcessor
public QueryProcessor()Default constructor.
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the query processor after construction. This method creates the initial filter chain from the registered filters. Called automatically by the DI container after bean construction. -
execute
public org.opensearch.index.query.QueryBuilder execute(QueryContext context, org.apache.lucene.search.Query query, float boost) Executes query processing through the filter chain.- Parameters:
context- the query context containing search parameters and statequery- the Lucene query to be processedboost- the boost factor to apply to the query- Returns:
- the processed OpenSearch QueryBuilder
-
add
Adds a query command to the processor.- Parameters:
name- the name to associate with the command (typically the query class simple name)queryCommand- the query command implementation to add- Throws:
IllegalArgumentException- if name or queryCommand is null
-
addFilter
Adds a filter to the processing pipeline. After adding a filter, the filter chain is recreated to include the new filter.- Parameters:
filter- the filter to add to the processing pipeline
-
createFilterChain
protected void createFilterChain()Creates the filter chain from the registered filters. The chain starts with the default filter chain and appends each registered filter. -
appendFilterChain
protected QueryProcessor.FilterChain appendFilterChain(QueryProcessor.Filter filter, QueryProcessor.FilterChain chain) Appends a filter to an existing filter chain.- Parameters:
filter- the filter to appendchain- the existing filter chain to append to- Returns:
- a new filter chain that includes the appended filter
-
createDefaultFilterChain
Creates the default filter chain that executes query commands. This chain looks up the appropriate query command based on the query class name and executes it. If no command is found, throws an InvalidQueryException.- Returns:
- the default filter chain implementation
-