diff --git a/src/main/java/org/codelibs/fess/helper/ViewHelper.java b/src/main/java/org/codelibs/fess/helper/ViewHelper.java
index 8be873d9e..35e661291 100644
--- a/src/main/java/org/codelibs/fess/helper/ViewHelper.java
+++ b/src/main/java/org/codelibs/fess/helper/ViewHelper.java
@@ -210,16 +210,21 @@ public class ViewHelper {
protected String escapeHighlight(final String text) {
final String escaped = LaFunctions.h(text);
- int pos = escaped.indexOf(escapedHighlightPre);
- while (pos >= 0) {
- final int c = escaped.codePointAt(pos);
- if (Character.isISOControl(c) || highlightTerminalCharSet.contains(c)) {
- break;
+ final String value;
+ if (ComponentUtil.getFessConfig().isQueryHighlightBoundaryPositionDetect()) {
+ int pos = escaped.indexOf(escapedHighlightPre);
+ while (pos >= 0) {
+ final int c = escaped.codePointAt(pos);
+ if (Character.isISOControl(c) || highlightTerminalCharSet.contains(c)) {
+ break;
+ }
+ pos--;
}
- pos--;
- }
- final String value = escaped.substring(pos + 1);
+ value = escaped.substring(pos + 1);
+ } else {
+ value = escaped;
+ }
return value.replaceAll(escapedHighlightPre, highlightTagPre).replaceAll(escapedHighlightPost, highlightTagPost);
}
diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
index 1d7235708..b9be15837 100644
--- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
+++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
@@ -708,6 +708,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/** 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. true */
+ String QUERY_HIGHLIGHT_BOUNDARY_POSITION_DETECT = "query.highlight.boundary.position.detect";
+
/** The key of the configuration. e.g. 100000 */
String QUERY_MAX_SEARCH_RESULT_OFFSET = "query.max.search.result.offset";
@@ -3568,6 +3571,20 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
*/
String getQueryHighlightContentDescriptionFields();
+ /**
+ * Get the value for the key 'query.highlight.boundary.position.detect'.
+ * The value is, e.g. true
+ * @return The value of found property. (NotNull: if not found, exception but basically no way)
+ */
+ String getQueryHighlightBoundaryPositionDetect();
+
+ /**
+ * Is the property for the key 'query.highlight.boundary.position.detect' true?
+ * The value is, e.g. true
+ * @return The determination, true or false. (if not found, exception but basically no way)
+ */
+ boolean isQueryHighlightBoundaryPositionDetect();
+
/**
* Get the value for the key 'query.max.search.result.offset'.
* The value is, e.g. 100000
@@ -7195,6 +7212,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
return get(FessConfig.QUERY_HIGHLIGHT_CONTENT_DESCRIPTION_FIELDS);
}
+ public String getQueryHighlightBoundaryPositionDetect() {
+ return get(FessConfig.QUERY_HIGHLIGHT_BOUNDARY_POSITION_DETECT);
+ }
+
+ public boolean isQueryHighlightBoundaryPositionDetect() {
+ return is(FessConfig.QUERY_HIGHLIGHT_BOUNDARY_POSITION_DETECT);
+ }
+
public String getQueryMaxSearchResultOffset() {
return get(FessConfig.QUERY_MAX_SEARCH_RESULT_OFFSET);
}
@@ -8750,6 +8775,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_ORDER, "score");
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_PHRASE_LIMIT, "256");
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_CONTENT_DESCRIPTION_FIELDS, "hl_content,digest");
+ defaultMap.put(FessConfig.QUERY_HIGHLIGHT_BOUNDARY_POSITION_DETECT, "true");
defaultMap.put(FessConfig.QUERY_MAX_SEARCH_RESULT_OFFSET, "100000");
defaultMap.put(FessConfig.QUERY_ADDITIONAL_DEFAULT_FIELDS, "");
defaultMap.put(FessConfig.QUERY_ADDITIONAL_RESPONSE_FIELDS, "");
diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties
index 2cf307d7d..74fb6e4b1 100644
--- a/src/main/resources/fess_config.properties
+++ b/src/main/resources/fess_config.properties
@@ -351,6 +351,7 @@ query.highlight.no.match.size=0
query.highlight.order=score
query.highlight.phrase.limit=256
query.highlight.content.description.fields=hl_content,digest
+query.highlight.boundary.position.detect=true
query.max.search.result.offset=100000
query.additional.default.fields=
query.additional.response.fields=