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

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


        {if (true) return q;}
    throw new Error("Missing return statement in function");
  }

  final public QueryNode Clause(CharSequence field) throws ParseException {
  QueryNode q;
  Token fieldToken=null, boost=null, operator=null, term=null;
  FieldQueryNode qLower, qUpper;
  boolean lowerInclusive, upperInclusive;

  boolean group = false;
View Full Code Here


  Token term, boost=null, fuzzySlop=null, goop1, goop2;
  boolean fuzzy = false;
  boolean regexp = false;
  boolean startInc=false;
  boolean endInc=false;
  QueryNode q =null;
  FieldQueryNode qLower, qUpper;
  float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case TERM:
    case REGEXPTERM:
View Full Code Here

  }

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

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

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

    return query;
View Full Code Here

  public void testBasicDemo() throws Exception {
    SyntaxParser queryParser = new StandardSyntaxParser();

    // convert the CharSequence into a QueryNode tree
    QueryNode queryTree = queryParser.parse("body:text", null);

    // create a config handler with a attribute used in
    // UniqueFieldQueryNodeProcessor
    QueryConfigHandler spanQueryConfigHandler = new SpansQueryConfigHandler();
    spanQueryConfigHandler.set(SpansQueryConfigHandler.UNIQUE_FIELD, "index");
View Full Code Here

  public SpanQuery getSpanQuery(String uniqueField, CharSequence query)
      throws QueryNodeException {
   
    this.spanQueryConfigHandler.set(SpansQueryConfigHandler.UNIQUE_FIELD, uniqueField);

    QueryNode queryTree = this.queryParser.parse(query, "defaultField");
    queryTree = this.spanProcessorPipeline.process(queryTree);

    return this.spansQueryTreeBuilder.build(queryTree);

  }
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

    if (node instanceof BooleanQueryNode) {
      List<QueryNode> children = node.getChildren();

      if (children != null && children.size() == 1) {
        QueryNode child = children.get(0);

        if (child instanceof ModifierQueryNode) {
          ModifierQueryNode modNode = (ModifierQueryNode) child;

          if (modNode instanceof BooleanModifierNode
View Full Code Here

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

    try {
      QueryNode result = null;
      switch (op) {
      case NONE:
        List<QueryNode> children = new ArrayList<>();
        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

    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

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.