fix #1582 highlight words in title
This commit is contained in:
parent
b7c3368028
commit
1aa6da600c
7 changed files with 43 additions and 8 deletions
|
@ -187,7 +187,9 @@ public class QueryHelper {
|
|||
fessConfig.getIndexFieldCache());
|
||||
}
|
||||
if (highlightedFields == null) {
|
||||
highlightedFields = fessConfig.getQueryAdditionalHighlightedFields(fessConfig.getIndexFieldContent());
|
||||
highlightedFields = fessConfig.getQueryAdditionalHighlightedFields( //
|
||||
fessConfig.getIndexFieldTitle(), //
|
||||
fessConfig.getIndexFieldContent());
|
||||
}
|
||||
if (searchFields == null) {
|
||||
searchFields = fessConfig.getQueryAdditionalSearchFields(//
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ViewHelper {
|
|||
|
||||
public String urlLinkEncoding = Constants.UTF_8;
|
||||
|
||||
public String[] highlightedFields = new String[] { "hl_content", "digest" };
|
||||
protected String[] highlightedFields;
|
||||
|
||||
public String originalHighlightTagPre = "<em>";
|
||||
|
||||
|
@ -143,16 +143,25 @@ public class ViewHelper {
|
|||
escapedHighlightPost = LaFunctions.h(originalHighlightTagPost);
|
||||
highlightTagPre = fessConfig.getQueryHighlightTagPre();
|
||||
highlightTagPost = fessConfig.getQueryHighlightTagPost();
|
||||
highlightedFields = fessConfig.getQueryHighlightContentDescriptionFieldsAsArray();
|
||||
}
|
||||
|
||||
public String getContentTitle(final Map<String, Object> document) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
String title = DocumentUtil.getValue(document, fessConfig.getIndexFieldTitle(), String.class);
|
||||
String title =
|
||||
DocumentUtil.getValue(document, ComponentUtil.getQueryHelper().getHighlightPrefix() + fessConfig.getIndexFieldTitle(),
|
||||
String.class);
|
||||
if (StringUtil.isBlank(title)) {
|
||||
title = DocumentUtil.getValue(document, fessConfig.getIndexFieldFilename(), String.class);
|
||||
title = DocumentUtil.getValue(document, fessConfig.getIndexFieldTitle(), String.class);
|
||||
if (StringUtil.isBlank(title)) {
|
||||
title = DocumentUtil.getValue(document, fessConfig.getIndexFieldUrl(), String.class);
|
||||
title = DocumentUtil.getValue(document, fessConfig.getIndexFieldFilename(), String.class);
|
||||
if (StringUtil.isBlank(title)) {
|
||||
title = DocumentUtil.getValue(document, fessConfig.getIndexFieldUrl(), String.class);
|
||||
}
|
||||
}
|
||||
title = LaFunctions.h(title);
|
||||
} else {
|
||||
title = escapeHighlight(title).replaceAll("\\.\\.\\.$", StringUtil.EMPTY);
|
||||
}
|
||||
final int size = fessConfig.getResponseMaxTitleLengthAsInteger();
|
||||
if (size > -1) {
|
||||
|
|
|
@ -578,6 +578,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. </strong> */
|
||||
String QUERY_HIGHLIGHT_TAG_POST = "query.highlight.tag.post";
|
||||
|
||||
/** The key of the configuration. e.g. hl_content,digest */
|
||||
String QUERY_HIGHLIGHT_CONTENT_DESCRIPTION_FIELDS = "query.highlight.content.description.fields";
|
||||
|
||||
/** The key of the configuration. e.g. 100000 */
|
||||
String QUERY_MAX_SEARCH_RESULT_OFFSET = "query.max.search.result.offset";
|
||||
|
||||
|
@ -3019,6 +3022,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
String getQueryHighlightTagPost();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.highlight.content.description.fields'. <br>
|
||||
* The value is, e.g. hl_content,digest <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryHighlightContentDescriptionFields();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.max.search.result.offset'. <br>
|
||||
* The value is, e.g. 100000 <br>
|
||||
|
@ -6545,6 +6555,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return get(FessConfig.QUERY_HIGHLIGHT_TAG_POST);
|
||||
}
|
||||
|
||||
public String getQueryHighlightContentDescriptionFields() {
|
||||
return get(FessConfig.QUERY_HIGHLIGHT_CONTENT_DESCRIPTION_FIELDS);
|
||||
}
|
||||
|
||||
public String getQueryMaxSearchResultOffset() {
|
||||
return get(FessConfig.QUERY_MAX_SEARCH_RESULT_OFFSET);
|
||||
}
|
||||
|
@ -8132,6 +8146,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_TYPE, "fvh");
|
||||
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_TAG_PRE, "<strong>");
|
||||
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_TAG_POST, "</strong>");
|
||||
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_CONTENT_DESCRIPTION_FIELDS, "hl_content,digest");
|
||||
defaultMap.put(FessConfig.QUERY_MAX_SEARCH_RESULT_OFFSET, "100000");
|
||||
defaultMap.put(FessConfig.QUERY_ADDITIONAL_RESPONSE_FIELDS, "");
|
||||
defaultMap.put(FessConfig.QUERY_ADDITIONAL_API_RESPONSE_FIELDS, "");
|
||||
|
|
|
@ -1821,4 +1821,12 @@ public interface FessProp {
|
|||
}
|
||||
return Arrays.stream(patterns).anyMatch(p -> p.matcher(referer).matches());
|
||||
}
|
||||
|
||||
String getQueryHighlightContentDescriptionFields();
|
||||
|
||||
public default String[] getQueryHighlightContentDescriptionFieldsAsArray() {
|
||||
return split(getQueryHighlightContentDescriptionFields(), ",").get(
|
||||
stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -289,6 +289,7 @@ query.highlight.number.of.fragments=3
|
|||
query.highlight.type=fvh
|
||||
query.highlight.tag.pre=<strong>
|
||||
query.highlight.tag.post=</strong>
|
||||
query.highlight.content.description.fields=hl_content,digest
|
||||
query.max.search.result.offset=100000
|
||||
query.additional.response.fields=
|
||||
query.additional.api.response.fields=
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
<c:forEach var="doc" varStatus="s" items="${documentItems}">
|
||||
<li class="col-sm-12">
|
||||
<h3 class="title">
|
||||
<a href="${doc.url_link}">${f:h(doc.content_title)}</a>
|
||||
<a href="${doc.url_link}">${doc.content_title}</a>
|
||||
</h3>
|
||||
<div class="body col-sm-10">
|
||||
${doc.content_description}
|
||||
|
@ -102,7 +102,7 @@
|
|||
class="btn btn-xs btn-danger"
|
||||
data-toggle="modal" data-target="#confirmToDelete"
|
||||
data-docid="${f:u(doc.doc_id)}"
|
||||
data-title="${f:h(doc.content_title)}"
|
||||
data-title="${doc.content_title}"
|
||||
data-url="${f:h(doc.url_link)}">
|
||||
<i class="fa fa-trash"></i>
|
||||
<la:message key="labels.search_list_button_delete" />
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<div>
|
||||
<h3 class="title ellipsis media-heading">
|
||||
<a class="link" href="${doc.url_link}" data-uri="${doc.url_link}"
|
||||
data-id="${doc.doc_id}" data-order="${s.index}">${f:h(doc.content_title)}</a>
|
||||
data-id="${doc.doc_id}" data-order="${s.index}">${doc.content_title}</a>
|
||||
</h3>
|
||||
<div class="body">
|
||||
<div>
|
||||
|
|
Loading…
Add table
Reference in a new issue