Namespace Lucene.Net.QueryParsers.Flexible.Core.Processors
Interfaces and implementations used by query node processors
Query Node Processors
The package org.apache.lucene.queryParser.processors contains interfaces that should be implemented by every query node processor.
The interface that every query node processor should implement is QueryNodeProcessor.
A query node processor should be used to process a QueryNode tree. QueryNode trees can be programmatically created or generated by a text parser. See Lucene.Net.QueryParsers.Flexible.Core.Parser for more details about text parsers.
A query node processor should be used to process a QueryNode tree. QueryNode trees can be programmatically created or generated by a text parser. See Lucene.Net.QueryParsers.Flexible.Core.Parser for more details about text parsers.
A pipeline of processors can be assembled using QueryNodeProcessorPipeline.
Implementors may want to extend <xref:Lucene.Net.QueryParsers.Flexible.Core.Processors.QueryNodeProcessorImpl>, which simplifies the implementation, because it walks automatically the QueryNode. See <xref:Lucene.Net.QueryParsers.Flexible.Core.Processors.QueryNodeProcessorImpl> for more details.
Classes
NoChildOptimizationQueryNodeProcessor
A NoChildOptimizationQueryNodeProcessor removes every BooleanQueryNode, BoostQueryNode, TokenizedPhraseQueryNode or ModifierQueryNode that do not have a valid children.
Example: When the children of these nodes are removed for any reason then the nodes may become invalid.
QueryNodeProcessor
This is a default implementation for the IQueryNodeProcessor interface, it's an abstract class, so it should be extended by classes that want to process a IQueryNode tree.
This class process IQueryNodes from left to right in the tree. While it's walking down the tree, for every node, PreProcessNode(IQueryNode) is invoked. After a node's children are processed, PostProcessNode(IQueryNode) is invoked for that node. SetChildrenOrder(IList<IQueryNode>) is invoked before PostProcessNode(IQueryNode) only if the node has at least one child, in SetChildrenOrder(IList<IQueryNode>) the implementor might redefine the children order or remove any children from the children list.
Here is an example about how it process the nodes:
a / \ b e / \ c d
Here is the order the methods would be invoked for the tree described above:
PreProcessNode( a );
PreProcessNode( b );
PreProcessNode( c );
PostProcessNode( c );
PreProcessNode( d );
PostProcessNode( d );
SetChildrenOrder( bChildrenList );
PostProcessNode( b );
PreProcessNode( e );
PostProcessNode( e );
SetChildrenOrder( aChildrenList );
PostProcessNode( a )
QueryNodeProcessorPipeline
A QueryNodeProcessorPipeline class should be used to build a query node processor pipeline.
When a query node tree is processed using this class, it passes the query node tree to each processor on the pipeline and the result from each processor is passed to the next one, always following the order the processors were on the pipeline.
When a QueryConfigHandler object is set on a QueryNodeProcessorPipeline, it also takes care of setting this QueryConfigHandler on all processor on pipeline.
RemoveDeletedQueryNodesProcessor
A QueryNodeProcessorPipeline class removes every instance of DeletedQueryNode from a query node tree. If the resulting root node is a DeletedQueryNode, MatchNoDocsQueryNode is returned.
Interfaces
IQueryNodeProcessor
An IQueryNodeProcessor is an interface for classes that process a IQueryNode tree.
The implementor of this class should perform some operation on a query node tree and return the same or another query node tree.
It also may carry a QueryConfigHandler object that contains configuration about the query represented by the query tree or the collection/index where it's intended to be executed.
In case there is any QueryConfigHandler associated to the query tree to be processed, it should be set using SetQueryConfigHandler(QueryConfigHandler) before Process(IQueryNode) is invoked.