Search in sources :

Example 1 with EscapeQuerySyntaxImpl

use of org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuerySyntaxImpl in project lucene-solr by apache.

the class BooleanQueryNodeBuilder method build.

@Override
public BooleanQuery build(QueryNode queryNode) throws QueryNodeException {
    BooleanQueryNode booleanNode = (BooleanQueryNode) queryNode;
    BooleanQuery.Builder bQuery = new BooleanQuery.Builder();
    List<QueryNode> children = booleanNode.getChildren();
    if (children != null) {
        for (QueryNode child : children) {
            Object obj = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
            if (obj != null) {
                Query query = (Query) obj;
                try {
                    bQuery.add(query, getModifierValue(child));
                } catch (TooManyClauses ex) {
                    throw new QueryNodeException(new MessageImpl(QueryParserMessages.TOO_MANY_BOOLEAN_CLAUSES, BooleanQuery.getMaxClauseCount(), queryNode.toQueryString(new EscapeQuerySyntaxImpl())), ex);
                }
            }
        }
    }
    return bQuery.build();
}
Also used : QueryNodeException(org.apache.lucene.queryparser.flexible.core.QueryNodeException) BooleanQuery(org.apache.lucene.search.BooleanQuery) Query(org.apache.lucene.search.Query) BooleanQuery(org.apache.lucene.search.BooleanQuery) BooleanQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode) ModifierQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode) QueryNode(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode) QueryTreeBuilder(org.apache.lucene.queryparser.flexible.core.builders.QueryTreeBuilder) BooleanQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode) TooManyClauses(org.apache.lucene.search.BooleanQuery.TooManyClauses) MessageImpl(org.apache.lucene.queryparser.flexible.messages.MessageImpl) EscapeQuerySyntaxImpl(org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuerySyntaxImpl)

Aggregations

QueryNodeException (org.apache.lucene.queryparser.flexible.core.QueryNodeException)1 QueryTreeBuilder (org.apache.lucene.queryparser.flexible.core.builders.QueryTreeBuilder)1 BooleanQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode)1 ModifierQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode)1 QueryNode (org.apache.lucene.queryparser.flexible.core.nodes.QueryNode)1 MessageImpl (org.apache.lucene.queryparser.flexible.messages.MessageImpl)1 EscapeQuerySyntaxImpl (org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuerySyntaxImpl)1 BooleanQuery (org.apache.lucene.search.BooleanQuery)1 TooManyClauses (org.apache.lucene.search.BooleanQuery.TooManyClauses)1 Query (org.apache.lucene.search.Query)1