Example usage for org.apache.lucene.queryparser.flexible.core.nodes FuzzyQueryNode getTextAsString

List of usage examples for org.apache.lucene.queryparser.flexible.core.nodes FuzzyQueryNode getTextAsString

Introduction

In this page you can find the example usage for org.apache.lucene.queryparser.flexible.core.nodes FuzzyQueryNode getTextAsString.

Prototype

public String getTextAsString() 

Source Link

Usage

From source file:com.sindicetech.siren.qparser.keyword.builders.NodeFuzzyQueryNodeBuilder.java

License:Open Source License

public NodeQuery build(QueryNode queryNode) throws QueryNodeException {
    FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) queryNode;
    String text = fuzzyNode.getTextAsString();

    int numEdits = FuzzyQuery.floatToEdits(fuzzyNode.getSimilarity(), text.codePointCount(0, text.length()));

    NodeFuzzyQuery fuzzyQuery = new NodeFuzzyQuery(
            new Term(fuzzyNode.getFieldAsString(), fuzzyNode.getTextAsString()), numEdits,
            fuzzyNode.getPrefixLength());
    // assign the datatype. We must always have a datatype assigned.
    fuzzyQuery.setDatatype((String) queryNode.getTag(DatatypeQueryNode.DATATYPE_TAGID));

    // if it is tagged as a span query
    if (fuzzyNode.getTag(QueryTypeProcessor.QUERYTYPE_TAG) == QueryTypeProcessor.SPAN_QUERYTYPE) {
        return new MultiTermSpanQuery<>(fuzzyQuery);
    } else {//  w  ww  .  jav  a2s. c  om
        return fuzzyQuery;
    }
}

From source file:org.sindice.siren.qparser.keyword.builders.NodeFuzzyQueryNodeBuilder.java

License:Apache License

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());
}