fix #985 display boosted docs
This commit is contained in:
parent
76f1663fd3
commit
a0c9686e1a
7 changed files with 38 additions and 0 deletions
|
@ -15,6 +15,10 @@
|
|||
*/
|
||||
package org.codelibs.fess.app.web.admin.keymatch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
|
@ -23,6 +27,7 @@ import org.codelibs.fess.app.service.KeyMatchService;
|
|||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.config.exentity.KeyMatch;
|
||||
import org.codelibs.fess.helper.KeyMatchHelper;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.RenderDataUtil;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
@ -42,6 +47,8 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
private KeyMatchHelper keyMatchHelper;
|
||||
@Resource
|
||||
private KeyMatchService keyMatchService;
|
||||
@Resource
|
||||
private KeyMatchPager keyMatchPager;
|
||||
|
@ -142,6 +149,7 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
public HtmlResponse details(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DETAILS);
|
||||
saveToken();
|
||||
final List<Map<String, Object>> docList = new ArrayList<>();
|
||||
return asHtml(path_AdminKeymatch_AdminKeymatchDetailsJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
keyMatchService.getKeyMatch(id).ifPresent(entity -> {
|
||||
|
@ -149,10 +157,13 @@ public class AdminKeymatchAction extends FessAdminAction {
|
|||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
docList.addAll(keyMatchHelper.getBoostedDocumentList(entity.getTerm(), entity.getMaxSize()));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
data.register("docs", docList);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,20 @@ public class KeyMatchHelper {
|
|||
});
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getBoostedDocumentList(final String term, final int size) {
|
||||
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
|
||||
final Pair<QueryBuilder, ScoreFunctionBuilder> pair = keyMatchQueryMap.get(toLowerCase(term));
|
||||
if (pair == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
return fessEsClient.getDocumentList(fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType(),
|
||||
searchRequestBuilder -> {
|
||||
searchRequestBuilder.setPreference(Constants.SEARCH_PREFERENCE_PRIMARY).setQuery(pair.getFirst()).setSize(size);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private String toLowerCase(final String term) {
|
||||
return term != null ? term.toLowerCase(Locale.ROOT) : term;
|
||||
}
|
||||
|
|
|
@ -1439,6 +1439,9 @@ public class FessLabels extends UserMessages {
|
|||
/** The key of the message: Boost */
|
||||
public static final String LABELS_key_match_boost = "{labels.key_match_boost}";
|
||||
|
||||
/** The key of the message: Urls */
|
||||
public static final String LABELS_key_match_urls = "{labels.key_match_urls}";
|
||||
|
||||
/** The key of the message: Key Match */
|
||||
public static final String LABELS_key_match_title_details = "{labels.key_match_title_details}";
|
||||
|
||||
|
|
|
@ -470,6 +470,7 @@ labels.key_match_term=Term
|
|||
labels.key_match_query=Query
|
||||
labels.key_match_size=Size
|
||||
labels.key_match_boost=Boost
|
||||
labels.key_match_urls=Urls
|
||||
labels.key_match_title_details=Key Match
|
||||
labels.design_configuration=Page Design
|
||||
labels.design_title_file_upload=File Upload
|
||||
|
|
|
@ -470,6 +470,7 @@ labels.key_match_term=Term
|
|||
labels.key_match_query=Query
|
||||
labels.key_match_size=Size
|
||||
labels.key_match_boost=Boost
|
||||
labels.key_match_urls=Urls
|
||||
labels.key_match_title_details=Key Match
|
||||
labels.design_configuration=Page Design
|
||||
labels.design_title_file_upload=File Upload
|
||||
|
|
|
@ -463,6 +463,7 @@ labels.key_match_term=\u691c\u7d22\u8a9e
|
|||
labels.key_match_query=\u30af\u30a8\u30ea\u30fc
|
||||
labels.key_match_size=\u30b5\u30a4\u30ba
|
||||
labels.key_match_boost=\u30d6\u30fc\u30b9\u30c8\u5024
|
||||
labels.key_match_urls=URL
|
||||
labels.key_match_title_details=\u30ad\u30fc\u30de\u30c3\u30c1
|
||||
labels.design_configuration=\u30da\u30fc\u30b8\u306e\u30c7\u30b6\u30a4\u30f3
|
||||
labels.design_title_file_upload=\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u30d5\u30a1\u30a4\u30eb
|
||||
|
|
|
@ -65,6 +65,13 @@
|
|||
<th><la:message key="labels.key_match_boost" /></th>
|
||||
<td>${f:h(boost)}<la:hidden property="boost" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><la:message key="labels.key_match_urls" /></th>
|
||||
<td><c:forEach var="doc" varStatus="s"
|
||||
items="${docs}">
|
||||
${f:h(doc.url)}<br/>
|
||||
</c:forEach></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue