fix #2242 add query.highlight.boundary.position.detect

This commit is contained in:
Shinsuke Sugaya 2019-09-07 18:40:58 +09:00
parent 5a656fa8c4
commit f5cc83de6a
3 changed files with 40 additions and 8 deletions

View file

@ -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);
}

View file

@ -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'. <br>
* The value is, e.g. true <br>
* @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? <br>
* The value is, e.g. true <br>
* @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'. <br>
* The value is, e.g. 100000 <br>
@ -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, "");

View file

@ -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=