Search in sources :

Example 1 with QueryNodeProcessor

use of org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor in project lucene-solr by apache.

the class QueryParserHelper method parse.

/**
   * Parses a query string to an object, usually some query object.<br>
   * <br>
   * In this method the three phases are executed: <br>
   * <br>
   * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1st - the query string is parsed using the
   * text parser returned by {@link #getSyntaxParser()}, the result is a query
   * node tree <br>
   * <br>
   * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2nd - the query node tree is processed by the
   * processor returned by {@link #getQueryNodeProcessor()} <br>
   * <br>
   * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3th - a object is built from the query node
   * tree using the builder returned by {@link #getQueryBuilder()}
   * 
   * @param query
   *          the query string
   * @param defaultField
   *          the default field used by the text parser
   * 
   * @return the object built from the query
   * 
   * @throws QueryNodeException
   *           if something wrong happens along the three phases
   */
public Object parse(String query, String defaultField) throws QueryNodeException {
    QueryNode queryTree = getSyntaxParser().parse(query, defaultField);
    QueryNodeProcessor processor = getQueryNodeProcessor();
    if (processor != null) {
        queryTree = processor.process(queryTree);
    }
    return getQueryBuilder().build(queryTree);
}
Also used : QueryNode(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode) QueryNodeProcessor(org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor)

Example 2 with QueryNodeProcessor

use of org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor in project lucene-solr by apache.

the class QueryParserHelper method setQueryConfigHandler.

/**
   * Sets the query configuration handler that will be used during query
   * processing. It can be <code>null</code>. It's also set to the processor
   * returned by {@link #getQueryNodeProcessor()}.
   * 
   * @param config
   *          the query configuration handler used during query processing, it
   *          can be <code>null</code>
   * 
   * @see #getQueryConfigHandler()
   * @see QueryConfigHandler
   */
public void setQueryConfigHandler(QueryConfigHandler config) {
    this.config = config;
    QueryNodeProcessor processor = getQueryNodeProcessor();
    if (processor != null) {
        processor.setQueryConfigHandler(config);
    }
}
Also used : QueryNodeProcessor(org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor)

Aggregations

QueryNodeProcessor (org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor)2 QueryNode (org.apache.lucene.queryparser.flexible.core.nodes.QueryNode)1