Skip to content

Commit

Permalink
Apply suggestion from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret committed Oct 25, 2024
1 parent 08c08f6 commit ee2f7f8
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public final class ParserUtils {
private static final String UNQUOTED_LITERAL_TERM_DELIMITER = " ";
private static final char ESCAPE_CHAR = '\\';
private static final char QUOTE_CHAR = '"';
private static final char WILDCARD_CHAR = '"';

private ParserUtils() {
throw new UnsupportedOperationException("No need to instantiate this class");
Expand Down Expand Up @@ -102,11 +103,11 @@ public static String escapeLuceneQueryString(String queryText, boolean preserveW
if (preserveWildcards) {
StringBuilder escapedQuery = new StringBuilder(queryText.length());
StringBuilder subpart = new StringBuilder(queryText.length());
for (int i = 0; i < queryText.length(); i++) {
char currentChar = queryText.charAt(i);
if (currentChar == '*') {

for (char currentChar : queryText.toCharArray()) {
if (currentChar == WILDCARD_CHAR) {
escapedQuery.append(QueryParser.escape(subpart.toString())).append(currentChar);
subpart = new StringBuilder(queryText.length() - i);
subpart.setLength(0);
} else {
subpart.append(currentChar);
}
Expand Down

0 comments on commit ee2f7f8

Please sign in to comment.