Search in sources :

Example 1 with OrQueryNode

use of org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode in project lucene-solr by apache.

the class StandardSyntaxParser method DisjQuery.

public final QueryNode DisjQuery(CharSequence field) throws ParseException {
    QueryNode first, c;
    Vector<QueryNode> clauses = null;
    first = ConjQuery(field);
    label_2: while (true) {
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case OR:
                ;
                break;
            default:
                jj_la1[3] = jj_gen;
                break label_2;
        }
        jj_consume_token(OR);
        c = ConjQuery(field);
        if (clauses == null) {
            clauses = new Vector<QueryNode>();
            clauses.addElement(first);
        }
        clauses.addElement(c);
    }
    if (clauses != null) {
        {
            if (true)
                return new OrQueryNode(clauses);
        }
    } else {
        {
            if (true)
                return first;
        }
    }
    throw new Error("Missing return statement in function");
}
Also used : OrQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode) RegexpQueryNode(org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode) GroupQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode) AndQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.AndQueryNode) FieldQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode) TermRangeQueryNode(org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode) BooleanQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode) BoostQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.BoostQueryNode) FuzzyQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode) ModifierQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode) QuotedFieldQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode) SlopQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode) OrQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode) QueryNode(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode) Vector(java.util.Vector)

Example 2 with OrQueryNode

use of org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode in project lucene-solr by apache.

the class MultiFieldQueryNodeProcessor method preProcessNode.

@Override
protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {
    if (node instanceof FieldableNode) {
        this.processChildren = false;
        FieldableNode fieldNode = (FieldableNode) node;
        if (fieldNode.getField() == null) {
            CharSequence[] fields = getQueryConfigHandler().get(ConfigurationKeys.MULTI_FIELDS);
            if (fields == null) {
                throw new IllegalArgumentException("StandardQueryConfigHandler.ConfigurationKeys.MULTI_FIELDS should be set on the QueryConfigHandler");
            }
            if (fields != null && fields.length > 0) {
                fieldNode.setField(fields[0]);
                if (fields.length == 1) {
                    return fieldNode;
                } else {
                    List<QueryNode> children = new ArrayList<>(fields.length);
                    children.add(fieldNode);
                    for (int i = 1; i < fields.length; i++) {
                        try {
                            fieldNode = (FieldableNode) fieldNode.cloneTree();
                            fieldNode.setField(fields[i]);
                            children.add(fieldNode);
                        } catch (CloneNotSupportedException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    return new GroupQueryNode(new OrQueryNode(children));
                }
            }
        }
    }
    return node;
}
Also used : FieldableNode(org.apache.lucene.queryparser.flexible.core.nodes.FieldableNode) OrQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode) BooleanQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode) OrQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode) QueryNode(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode) GroupQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode) ArrayList(java.util.ArrayList) GroupQueryNode(org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode)

Aggregations

BooleanQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode)2 GroupQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode)2 OrQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode)2 QueryNode (org.apache.lucene.queryparser.flexible.core.nodes.QueryNode)2 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1 AndQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.AndQueryNode)1 BoostQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.BoostQueryNode)1 FieldQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode)1 FieldableNode (org.apache.lucene.queryparser.flexible.core.nodes.FieldableNode)1 FuzzyQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.FuzzyQueryNode)1 ModifierQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode)1 QuotedFieldQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.QuotedFieldQueryNode)1 SlopQueryNode (org.apache.lucene.queryparser.flexible.core.nodes.SlopQueryNode)1 RegexpQueryNode (org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode)1 TermRangeQueryNode (org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode)1