Example usage for org.apache.lucene.search FuzzyQuery defaultMaxEdits

List of usage examples for org.apache.lucene.search FuzzyQuery defaultMaxEdits

Introduction

In this page you can find the example usage for org.apache.lucene.search FuzzyQuery defaultMaxEdits.

Prototype

int defaultMaxEdits

To view the source code for org.apache.lucene.search FuzzyQuery defaultMaxEdits.

Click Source Link

Usage

From source file:org.exist.indexing.lucene.XMLToQuery.java

License:Open Source License

private Query fuzzyQuery(String field, Element node) throws XPathException {
    int maxEdits = FuzzyQuery.defaultMaxEdits;
    String attr = node.getAttribute("max-edits");
    if (attr != null && attr.length() > 0) {
        try {//w w w.j a v a2s .c  om
            maxEdits = Integer.parseInt(attr);
            if (maxEdits < 0 || maxEdits > LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) {
                throw new XPathException("Query parameter max-edits must by <= "
                        + LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE);
            }
        } catch (NumberFormatException e) {
            throw new XPathException("Query parameter 'max-edits' should be an integer value. Got: " + attr);
        }
    }
    return new FuzzyQuery(new Term(field, getText(node)), maxEdits);
}