Package org.apache.lucene.queryparser.flexible.core.nodes

Examples of org.apache.lucene.queryparser.flexible.core.nodes.QueryNode


        if (obj != null) {
          final Query query = (Query) obj;

          try {
            final QueryNode mod;
            if (child instanceof DatatypeQueryNode) {
              mod = ((DatatypeQueryNode) child).getChild();
            } else {
              mod = child;
            }
View Full Code Here


    // empty constructor
  }

  public Query build(final QueryNode queryNode) throws QueryNodeException {
    final BoostQueryNode boostNode = (BoostQueryNode) queryNode;
    final QueryNode child = boostNode.getChild();

    if (child == null) {
      return null;
    }

    final Query query = (Query) child
        .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
    query.setBoost(boostNode.getValue());

    return query;
  }
View Full Code Here

    return node;
   
  }
 
  protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {
    QueryNode parent = node.getParent();
    if (node instanceof BooleanQueryNode) {
      if (parent instanceof BooleanQueryNode) {
        node.setTag(TAG_REMOVE, Boolean.TRUE); // no precedence
      } else {
        node.setTag(TAG_BOOLEAN_ROOT, Boolean.TRUE);
View Full Code Here

    readTree(queryTree);

    List<QueryNode> actualQueryNodeList = this.queryNodeList;

    for (int i = 0; i < actualQueryNodeList.size(); i++) {
      QueryNode node = actualQueryNodeList.get(i);

      if (node instanceof GroupQueryNode) {
        actualQueryNodeList.set(i, process(node));
      }
View Full Code Here

            return new GroupQueryNode(
                new StandardBooleanQueryNode(children, positionCount==1));
           
          } else {
            // multiple positions
            QueryNode q = new StandardBooleanQueryNode(Collections.<QueryNode>emptyList(),false);
            QueryNode currentQuery = null;
            for (int i = 0; i < numTokens; i++) {
              String term = null;
              try {
                boolean hasNext = buffer.incrementToken();
                assert hasNext == true;
                term = termAtt.toString();
              } catch (IOException e) {
                // safe to ignore, because we know the number of tokens
              }
              if (posIncrAtt != null && posIncrAtt.getPositionIncrement() == 0) {
                if (!(currentQuery instanceof BooleanQueryNode)) {
                  QueryNode t = currentQuery;
                  currentQuery = new StandardBooleanQueryNode(Collections.<QueryNode>emptyList(), true);
                  ((BooleanQueryNode)currentQuery).add(t);
                }
                ((BooleanQueryNode)currentQuery).add(new FieldQueryNode(field, term, -1, -1));
              } else {
View Full Code Here

      op = ANDOperation.Q2;
    else
      op = ANDOperation.NONE;

    try {
      QueryNode result = null;
      switch (op) {
      case NONE:
        List<QueryNode> children = new ArrayList<QueryNode>();
        children.add(q1.cloneTree());
        children.add(q2.cloneTree());
        result = new AndQueryNode(children);
        return result;
      case Q1:
        result = q1.cloneTree();
        result.add(q2.cloneTree());
        return result;
      case Q2:
        result = q2.cloneTree();
        result.add(q1.cloneTree());
        return result;
      case BOTH:
        result = q1.cloneTree();
        result.add(q2.cloneTree().getChildren());
        return result;
      }
    } catch (CloneNotSupportedException e) {
      throw new QueryNodeError(e);
    }
View Full Code Here

     */
    public QueryNode parse(CharSequence query, CharSequence field) throws QueryNodeParseException {
      ReInit(new FastCharStream(new StringReader(query.toString())));
      try {
        // TopLevelQuery is a Query followed by the end-of-input (EOF)
        QueryNode querynode = TopLevelQuery(field);
        return querynode;
      }
      catch (ParseException tme) {
            tme.setQuery(query);
            throw tme;
View Full Code Here

    throw new Error("Missing return statement in function");
  }

// This makes sure that there is no garbage after the query string
  final public QueryNode TopLevelQuery(CharSequence field) throws ParseException {
  QueryNode q;
    q = Query(field);
    jj_consume_token(0);
    {if (true) return q;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

//   DisjQuery ::= ConjQuery ( OR ConjQuery )*
//   ConjQuery ::= Clause ( AND Clause )*
//      Clause ::= [ Modifier ] ...
  final public QueryNode Query(CharSequence field) throws ParseException {
  Vector<QueryNode> clauses = null;
  QueryNode c, first=null;
    first = DisjQuery(field);
    label_1:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case NOT:
View Full Code Here

      }
    throw new Error("Missing return statement in function");
  }

  final public 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) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryparser.flexible.core.nodes.QueryNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.