Class QueryProcessor

java.lang.Object
org.codelibs.fess.query.QueryProcessor

public class QueryProcessor extends Object
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.

  • Field Details

    • queryCommandMap

      protected Map<String,QueryCommand> queryCommandMap
      Map of query commands indexed by query class simple names. Used to lookup appropriate command handlers for different query types.
    • filterList

      protected List<QueryProcessor.Filter> filterList
      List of filters that will be applied during query processing. Filters are applied in the order they are added to this list.
    • filterChain

      protected QueryProcessor.FilterChain 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 state
      query - the Lucene query to be processed
      boost - the boost factor to apply to the query
      Returns:
      the processed OpenSearch QueryBuilder
    • add

      public void add(String name, QueryCommand queryCommand)
      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

      public void addFilter(QueryProcessor.Filter filter)
      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 append
      chain - the existing filter chain to append to
      Returns:
      a new filter chain that includes the appended filter
    • createDefaultFilterChain

      protected QueryProcessor.FilterChain 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