Class QueryParserHelper
java.lang.Object
org.apache.lucene.queryparser.flexible.core.QueryParserHelper
- Direct Known Subclasses:
StandardQueryParser
This class is a helper for the query parser framework, it does all the three query parser phrases
at once: text parsing, query processing and query building.
It contains methods that allows the user to change the implementation used on the three phases.
-
Constructor Summary
ConstructorDescriptionQueryParserHelper
(QueryConfigHandler queryConfigHandler, SyntaxParser syntaxParser, QueryNodeProcessor processor, QueryBuilder builder) Creates a query parser helper object using the specified configuration, text parser, processor and builder. -
Method Summary
Modifier and TypeMethodDescriptionReturns the query builder used to build a object from the query node tree.Returns the query configuration handler, which is used during the query node tree processing.Returns the processor object used to process the query node tree, it returnsnull
if no processor is used.Returns the text parser used to build a query node tree from a query string.Parses a query string to an object, usually some query object.
In this method the three phases are executed:
1st - the query string is parsed using the text parser returned bygetSyntaxParser()
, the result is a query node tree
2nd - the query node tree is processed by the processor returned bygetQueryNodeProcessor()
3th - a object is built from the query node tree using the builder returned bygetQueryBuilder()
void
setQueryBuilder
(QueryBuilder queryBuilder) The query builder that will be used to build an object from the query node tree.void
Sets the query configuration handler that will be used during query processing.void
setQueryNodeProcessor
(QueryNodeProcessor processor) Sets the processor that will be used to process the query node tree.void
setSyntaxParser
(SyntaxParser syntaxParser) Sets the text parser that will be used to parse the query string, it cannot benull
.
-
Constructor Details
-
QueryParserHelper
public QueryParserHelper(QueryConfigHandler queryConfigHandler, SyntaxParser syntaxParser, QueryNodeProcessor processor, QueryBuilder builder) Creates a query parser helper object using the specified configuration, text parser, processor and builder.- Parameters:
queryConfigHandler
- the query configuration handler that will be initially set to this helpersyntaxParser
- the text parser that will be initially set to this helperprocessor
- the query processor that will be initially set to this helperbuilder
- the query builder that will be initially set to this helper- See Also:
-
-
Method Details
-
getQueryNodeProcessor
Returns the processor object used to process the query node tree, it returnsnull
if no processor is used.- Returns:
- the actual processor used to process the query node tree,
null
if no processor is used - See Also:
-
setQueryNodeProcessor
Sets the processor that will be used to process the query node tree. If there is anyQueryConfigHandler
returned bygetQueryConfigHandler()
, it will be set on the processor. The argument can benull
, which means that no processor will be used to process the query node tree.- Parameters:
processor
- the processor that will be used to process the query node tree, this argument can benull
- See Also:
-
setSyntaxParser
Sets the text parser that will be used to parse the query string, it cannot benull
.- Parameters:
syntaxParser
- the text parser that will be used to parse the query string- See Also:
-
setQueryBuilder
The query builder that will be used to build an object from the query node tree. It cannot benull
.- Parameters:
queryBuilder
- the query builder used to build something from the query node tree- See Also:
-
getQueryConfigHandler
Returns the query configuration handler, which is used during the query node tree processing. It can benull
.- Returns:
- the query configuration handler used on the query processing,
null
if not query configuration handler is defined - See Also:
-
getQueryBuilder
Returns the query builder used to build a object from the query node tree. The object produced by this builder is returned byparse(String, String)
.- Returns:
- the query builder
- See Also:
-
getSyntaxParser
Returns the text parser used to build a query node tree from a query string. The default text parser instance returned by this method is aSyntaxParser
.- Returns:
- the text parse used to build query node trees.
- See Also:
-
setQueryConfigHandler
Sets the query configuration handler that will be used during query processing. It can benull
. It's also set to the processor returned bygetQueryNodeProcessor()
.- Parameters:
config
- the query configuration handler used during query processing, it can benull
- See Also:
-
parse
Parses a query string to an object, usually some query object.
In this method the three phases are executed:
1st - the query string is parsed using the text parser returned bygetSyntaxParser()
, the result is a query node tree
2nd - the query node tree is processed by the processor returned bygetQueryNodeProcessor()
3th - a object is built from the query node tree using the builder returned bygetQueryBuilder()
- Parameters:
query
- the query stringdefaultField
- the default field used by the text parser- Returns:
- the object built from the query
- Throws:
QueryNodeException
- if something wrong happens along the three phases
-