bruno-roustant commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker URL: https://github.com/apache/lucene-solr/pull/1103#discussion_r360348691
########## File path: lucene/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java ########## @@ -317,7 +332,11 @@ public void setDistance(StringDistance distance) { SuggestMode suggestMode, float accuracy) throws IOException { final CharsRefBuilder spare = new CharsRefBuilder(); String text = term.text(); - if (minQueryLength > 0 && text.codePointCount(0, text.length()) < minQueryLength) + + int textLength = text.codePointCount(0, text.length()); + if (minQueryLength > 0 && textLength < minQueryLength) + return new SuggestWord[0]; + if (maxQueryLength > 0 && textLength > maxQueryLength) Review comment: Here we could group the "if" check, remove the maxQueryLength > 0 condition (with maxQueryLength initialized to Integer.MAX_VALUE), and have only one return empty array because this is the same semantic (and add brackets). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org