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

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


  public NodeFuzzyQueryNodeBuilder() {
    // empty constructor
  }

  public NodeFuzzyQuery build(QueryNode queryNode) throws QueryNodeException {
    FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) queryNode;
    String text = fuzzyNode.getTextAsString();
   
    int numEdits = FuzzyQuery.floatToEdits(fuzzyNode.getSimilarity(),
        text.codePointCount(0, text.length()));

    return new NodeFuzzyQuery(new Term(fuzzyNode.getFieldAsString(), fuzzyNode
        .getTextAsString()), numEdits, fuzzyNode
        .getPrefixLength());
  }
View Full Code Here


          if(fms < 0.0f){
            {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));}
          } else if (fms >= 1.0f && fms != (int) fms) {
            {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_EDITS));}
          }
          q = new FuzzyQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), fms, term.beginColumn, term.endColumn);
       } else if (regexp) {
         String re = term.image.substring(1, term.image.length()-1);
         q = new RegexpQueryNode(field, re, 0, re.length());
       }
      break;
View Full Code Here

          if(fms < 0.0f){
            {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));}
          } else if (fms >= 1.0f && fms != (int) fms) {
            {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_EDITS));}
          }
          q = new FuzzyQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), fms, term.beginColumn, term.endColumn);
       } else if (regexp) {
         String re = term.image.substring(1, term.image.length()-1);
         q = new RegexpQueryNode(field, re, 0, re.length());
       }
      break;
View Full Code Here

    // empty constructor
  }

  @Override
  public FuzzyQuery build(QueryNode queryNode) throws QueryNodeException {
    FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) queryNode;
    String text = fuzzyNode.getTextAsString();
   
    int numEdits = FuzzyQuery.floatToEdits(fuzzyNode.getSimilarity(),
        text.codePointCount(0, text.length()));
   
    return new FuzzyQuery(new Term(fuzzyNode.getFieldAsString(), fuzzyNode
        .getTextAsString()), numEdits, fuzzyNode
        .getPrefixLength());

  }
View Full Code Here

  @Override
  protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {

    if (node instanceof FuzzyQueryNode) {
      FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) node;
      QueryConfigHandler config = getQueryConfigHandler();

      FuzzyConfig fuzzyConfig = null;
     
      if (config != null && (fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG)) != null) {
        fuzzyNode.setPrefixLength(fuzzyConfig.getPrefixLength());

        if (fuzzyNode.getSimilarity() < 0) {
          fuzzyNode.setSimilarity(fuzzyConfig.getMinSimilarity());
        }
       
      } else if (fuzzyNode.getSimilarity() < 0) {
        throw new IllegalArgumentException("No FUZZY_CONFIG set in the config");
      }

    }
View Full Code Here

          if(fms < 0.0f){
            {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));}
          } else if (fms >= 1.0f && fms != (int) fms) {
            {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_EDITS));}
          }
          q = new FuzzyQueryNode(field, EscapeQuerySyntaxImpl.discardEscapeChar(term.image), fms, term.beginColumn, term.endColumn);
       } else if (regexp) {
         String re = term.image.substring(1, term.image.length()-1);
         q = new RegexpQueryNode(field, re, 0, re.length());
       }
      break;
View Full Code Here

TOP

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

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.