oracle / opengrok

OpenGrok is a fast and usable source code search and cross reference engine, written in Java
http://oracle.github.io/opengrok/
Other
4.34k stars 745 forks source link

/SuggesterQueryParser.java: floatToEdits(float,int) in org.apache.lucene.search.FuzzyQuery has been deprecated #2452

Open vladak opened 5 years ago

vladak commented 5 years ago

javac gives this warning when compiling the suggester code in opengrok-web module:

opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/query/SuggesterQueryParser.java:[233,38] floatToEdits(float,int) in org.apache.lucene.search.FuzzyQuery has been deprecated

The Lucene javadoc https://lucene.apache.org/core/6_6_1/core/org/apache/lucene/search/FuzzyQuery.html says:

static int | floatToEdits(float minimumSimilarity, int termLen) Deprecated.  pass integer edit distances instead.

ahornace commented 5 years ago

Yes, but if you look at the actual implementation in Lucene, then you will notice they use it there still as well. I took it from there :D so I was not sure if there was an equivalent.

vladak commented 5 years ago

I will just suppress the warning for #2246 however the suggestion to use integer distances needs to be investigated.

ahornace commented 5 years ago

From Lucene 7.4.0 :

protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
        String text = term.text();
        int numEdits = FuzzyQuery.floatToEdits(minimumSimilarity, text.codePointCount(0, text.length()));
        return new FuzzyQuery(term, numEdits, prefixLength);
    }
vladak commented 5 years ago

Yeah, just reached similar code on http://demo.opengrok.org/xref/lucene-solr/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java?r=10b7be59#594 :-) Given the Lucene itself will have to deal with this maybe we can just wait for them.