|
19 | 19 | import java.io.InputStream;
|
20 | 20 | import java.text.Normalizer;
|
21 | 21 | import java.util.*;
|
| 22 | +import java.util.stream.Collectors; |
22 | 23 |
|
| 24 | +import org.apache.commons.collections.CollectionUtils; |
23 | 25 | import org.apache.commons.lang.StringUtils;
|
24 | 26 | import org.exoplatform.social.metadata.favorite.FavoriteService;
|
25 | 27 | import org.exoplatform.wiki.utils.Utils;
|
@@ -133,26 +135,28 @@ protected List<SearchResult> filteredWikiSearch(String query, String userId, Lis
|
133 | 135 | }
|
134 | 136 |
|
135 | 137 | private String buildTagsQueryStatement(List<String> values) {
|
136 |
| - if (values == null || values.isEmpty()) { |
| 138 | + if (CollectionUtils.isEmpty(values)) { |
137 | 139 | return "";
|
138 | 140 | }
|
139 | 141 | List<String> tagsQueryParts = values.stream()
|
140 |
| - .map(value -> """ |
141 |
| - {"term": { |
142 |
| - "metadatas.tags.metadataName.keyword": { |
143 |
| - "value":""" + value + """ |
144 |
| - ,"case_insensitive":true |
145 |
| - } |
146 |
| - }} |
147 |
| - """) |
148 |
| - .toList(); |
149 |
| - return """ |
150 |
| - ,"should": ["""+ |
151 |
| - StringUtils.join(tagsQueryParts, ",") + """ |
152 |
| - ], |
153 |
| - "minimum_should_match": 1"""; |
| 142 | + .map(value -> new StringBuilder().append("{\"term\": {\n") |
| 143 | + .append(" \"metadatas.tags.metadataName.keyword\": {\n") |
| 144 | + .append(" \"value\": \"") |
| 145 | + .append(value) |
| 146 | + .append("\",\n") |
| 147 | + .append(" \"case_insensitive\":true\n") |
| 148 | + .append(" }\n") |
| 149 | + .append(" }}") |
| 150 | + .toString()) |
| 151 | + .collect(Collectors.toList()); |
| 152 | + return new StringBuilder().append(",\"should\": [\n") |
| 153 | + .append(org.apache.commons.lang3.StringUtils.join(tagsQueryParts, ",")) |
| 154 | + .append(" ],\n") |
| 155 | + .append(" \"minimum_should_match\": 1") |
| 156 | + .toString(); |
154 | 157 | }
|
155 | 158 |
|
| 159 | + |
156 | 160 | private String buildTermQuery(String termQuery) {
|
157 | 161 | if (StringUtils.isBlank(termQuery)) {
|
158 | 162 | return "";
|
|
0 commit comments