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

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

Introduction

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

Prototype

public String getFieldAsString() 

Source Link

Document

returns null if the field was not specified in the query string

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 {/*from ww  w . ja  v  a  2s .  c o  m*/
        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());
}