fix #1581 add query.highlight.tag.pre/post

This commit is contained in:
Shinsuke Sugaya 2018-03-29 22:25:28 +09:00
parent 86d94566f1
commit ef234fef50
3 changed files with 44 additions and 9 deletions

View file

@ -112,34 +112,37 @@ public class ViewHelper {
public String originalHighlightTagPost = "</em>";
public String highlightTagPre = "<strong>";
protected String highlightTagPre;
public String highlightTagPost = "</strong>";
protected String highlightTagPost;
protected boolean useSession = true;
private final Map<String, String> pageCacheMap = new ConcurrentHashMap<>();
protected final Map<String, String> pageCacheMap = new ConcurrentHashMap<>();
private final Map<String, String> initFacetParamMap = new HashMap<>();
protected final Map<String, String> initFacetParamMap = new HashMap<>();
private final Map<String, String> initGeoParamMap = new HashMap<>();
protected final Map<String, String> initGeoParamMap = new HashMap<>();
private final List<FacetQueryView> facetQueryViewList = new ArrayList<>();
protected final List<FacetQueryView> facetQueryViewList = new ArrayList<>();
public String cacheTemplateName = "cache";
private String escapedHighlightPre = null;
protected String escapedHighlightPre = null;
private String escapedHighlightPost = null;
protected String escapedHighlightPost = null;
protected ActionHook actionHook = new ActionHook();
private final Set<String> inlineMimeTypeSet = new HashSet<>();
protected final Set<String> inlineMimeTypeSet = new HashSet<>();
@PostConstruct
public void init() {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
escapedHighlightPre = LaFunctions.h(originalHighlightTagPre);
escapedHighlightPost = LaFunctions.h(originalHighlightTagPost);
highlightTagPre = fessConfig.getQueryHighlightTagPre();
highlightTagPost = fessConfig.getQueryHighlightTagPost();
}
public String getContentTitle(final Map<String, Object> document) {

View file

@ -572,6 +572,12 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/** The key of the configuration. e.g. fvh */
String QUERY_HIGHLIGHT_TYPE = "query.highlight.type";
/** The key of the configuration. e.g. &lt;strong&gt; */
String QUERY_HIGHLIGHT_TAG_PRE = "query.highlight.tag.pre";
/** The key of the configuration. e.g. &lt;/strong&gt; */
String QUERY_HIGHLIGHT_TAG_POST = "query.highlight.tag.post";
/** The key of the configuration. e.g. 100000 */
String QUERY_MAX_SEARCH_RESULT_OFFSET = "query.max.search.result.offset";
@ -2999,6 +3005,20 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
*/
String getQueryHighlightType();
/**
* Get the value for the key 'query.highlight.tag.pre'. <br>
* The value is, e.g. &lt;strong&gt; <br>
* @return The value of found property. (NotNull: if not found, exception but basically no way)
*/
String getQueryHighlightTagPre();
/**
* Get the value for the key 'query.highlight.tag.post'. <br>
* The value is, e.g. &lt;/strong&gt; <br>
* @return The value of found property. (NotNull: if not found, exception but basically no way)
*/
String getQueryHighlightTagPost();
/**
* Get the value for the key 'query.max.search.result.offset'. <br>
* The value is, e.g. 100000 <br>
@ -6517,6 +6537,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
return get(FessConfig.QUERY_HIGHLIGHT_TYPE);
}
public String getQueryHighlightTagPre() {
return get(FessConfig.QUERY_HIGHLIGHT_TAG_PRE);
}
public String getQueryHighlightTagPost() {
return get(FessConfig.QUERY_HIGHLIGHT_TAG_POST);
}
public String getQueryMaxSearchResultOffset() {
return get(FessConfig.QUERY_MAX_SEARCH_RESULT_OFFSET);
}
@ -8102,6 +8130,8 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_FRAGMENT_SIZE, "40");
defaultMap.put(FessConfig.QUERY_HIGHLIGHT_NUMBER_OF_FRAGMENTS, "3");
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_MAX_SEARCH_RESULT_OFFSET, "100000");
defaultMap.put(FessConfig.QUERY_ADDITIONAL_RESPONSE_FIELDS, "");
defaultMap.put(FessConfig.QUERY_ADDITIONAL_API_RESPONSE_FIELDS, "");

View file

@ -287,6 +287,8 @@ query.replace.term.with.prefix.query=true
query.highlight.fragment.size=40
query.highlight.number.of.fragments=3
query.highlight.type=fvh
query.highlight.tag.pre=<strong>
query.highlight.tag.post=</strong>
query.max.search.result.offset=100000
query.additional.response.fields=
query.additional.api.response.fields=