Commit eef092424abf9d0886606a470ed7cecd8d0a3b7c
1 parent
b0102f52
FullTextSearch performance improvement
Showing
1 changed file
with
4 additions
and
8 deletions
@@ -550,14 +550,10 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { | @@ -550,14 +550,10 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { | ||
550 | 550 | ||
551 | private String buildTextSearchQuery(QueryContext ctx, List<EntityKeyMapping> selectionMapping, String searchText) { | 551 | private String buildTextSearchQuery(QueryContext ctx, List<EntityKeyMapping> selectionMapping, String searchText) { |
552 | if (!StringUtils.isEmpty(searchText) && !selectionMapping.isEmpty()) { | 552 | if (!StringUtils.isEmpty(searchText) && !selectionMapping.isEmpty()) { |
553 | - String lowerSearchText = searchText.toLowerCase() + "%"; | ||
554 | - List<String> searchPredicates = selectionMapping.stream().map(mapping -> { | ||
555 | - String paramName = mapping.getValueAlias() + "_lowerSearchText"; | ||
556 | - ctx.addStringParameter(paramName, lowerSearchText); | ||
557 | - return String.format("LOWER(%s) LIKE concat('%%', :%s, '%%')", mapping.getValueAlias(), paramName); | ||
558 | - } | ||
559 | - ).collect(Collectors.toList()); | ||
560 | - return String.format(" WHERE %s", String.join(" or ", searchPredicates)); | 553 | + String lowerSearchText = "%" + searchText.toLowerCase() + "%"; |
554 | + ctx.addStringParameter("lowerSearchTextParam", lowerSearchText); | ||
555 | + List<String> searchAliases = selectionMapping.stream().map(EntityKeyMapping::getValueAlias).collect(Collectors.toList()); | ||
556 | + return String.format(" WHERE LOWER(CONCAT(%s)) LIKE :%s", String.join(" , ", searchAliases), "lowerSearchTextParam"); | ||
561 | } else { | 557 | } else { |
562 | return ""; | 558 | return ""; |
563 | } | 559 | } |