modify cache page
This commit is contained in:
parent
a773489738
commit
e78e87dc87
4 changed files with 18 additions and 15 deletions
|
@ -54,7 +54,7 @@ public class CacheAction extends FessSearchAction {
|
|||
doc = fessEsClient.getDocument(fessConfig.getIndexDocumentIndex(), fessConfig.getIndexDocumentType(), queryRequestBuilder -> {
|
||||
final TermQueryBuilder termQuery = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), form.docId);
|
||||
queryRequestBuilder.setQuery(termQuery);
|
||||
queryRequestBuilder.addFields(queryHelper.getResponseFields());
|
||||
queryRequestBuilder.addFields(queryHelper.getCacheResponseFields());
|
||||
return true;
|
||||
}).get();
|
||||
} catch (final Exception e) {
|
||||
|
|
|
@ -39,23 +39,24 @@ public class QueryContext {
|
|||
|
||||
private final String queryString;
|
||||
|
||||
private final Set<String> highlightedQuerySet = new HashSet<>();
|
||||
private Set<String> highlightedQuerySet = null;
|
||||
|
||||
private Map<String, List<String>> fieldLogMap = null;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public QueryContext(final String queryString, final boolean fieldLogEnable) {
|
||||
public QueryContext(final String queryString, final boolean isQuery) {
|
||||
this.queryString = queryString;
|
||||
LaRequestUtil.getOptionalRequest().ifPresent(request -> {
|
||||
request.setAttribute(Constants.HIGHLIGHT_QUERIES, highlightedQuerySet);
|
||||
if (fieldLogEnable) {
|
||||
if (isQuery) {
|
||||
LaRequestUtil.getOptionalRequest().ifPresent(request -> {
|
||||
highlightedQuerySet = new HashSet<>();
|
||||
request.setAttribute(Constants.HIGHLIGHT_QUERIES, highlightedQuerySet);
|
||||
fieldLogMap = (Map<String, List<String>>) request.getAttribute(Constants.FIELD_LOGS);
|
||||
if (fieldLogMap == null) {
|
||||
fieldLogMap = new HashMap<>();
|
||||
request.setAttribute(Constants.FIELD_LOGS, fieldLogMap);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void addQuery(final Consumer<BoolQueryBuilder> boolQuery) {
|
||||
|
@ -107,7 +108,9 @@ public class QueryContext {
|
|||
}
|
||||
|
||||
public void addHighlightedQuery(String text) {
|
||||
highlightedQuerySet.add(text);
|
||||
if (highlightedQuerySet != null) {
|
||||
highlightedQuerySet.add(text);
|
||||
}
|
||||
}
|
||||
|
||||
public String getQueryString() {
|
||||
|
|
|
@ -398,15 +398,15 @@ public class ViewHelper implements Serializable {
|
|||
if (locale == null) {
|
||||
locale = Locale.ENGLISH;
|
||||
}
|
||||
String url = DocumentUtil.getValue(doc, "urlLink", String.class);
|
||||
String url = DocumentUtil.getValue(doc, "url", String.class);
|
||||
if (url == null) {
|
||||
url = ComponentUtil.getMessageManager().getMessage(locale, "labels.search_unknown");
|
||||
}
|
||||
String createdStr;
|
||||
final Long created = DocumentUtil.getValue(doc, fessConfig.getIndexFieldCreated(), Long.class);
|
||||
final Date created = DocumentUtil.getValue(doc, fessConfig.getIndexFieldCreated(), Date.class);
|
||||
if (created != null) {
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND);
|
||||
createdStr = sdf.format(new Date(created.longValue()));
|
||||
createdStr = sdf.format(created);
|
||||
} else {
|
||||
createdStr = ComponentUtil.getMessageManager().getMessage(locale, "labels.search_unknown");
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ public class ViewHelper implements Serializable {
|
|||
|
||||
doc.put("queries", queries);
|
||||
|
||||
String cache = (String) doc.get(fessConfig.getIndexFieldCache());
|
||||
String cache = DocumentUtil.getValue(doc, fessConfig.getIndexFieldCache(), String.class);
|
||||
if (cache != null) {
|
||||
cache = pathMappingHelper.replaceUrls(cache);
|
||||
if (queries != null && queries.length > 0) {
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
<div class="description">${doc.contentDescription}</div>
|
||||
<div class="site ellipsis">
|
||||
<cite>${f:h(doc.sitePath)}</cite>
|
||||
<c:if test="${doc.hasCache_s_s=='true'}">
|
||||
<la:link href="/cache/?docId=${doc.doc_id}${appendHighlightQueries}" class="cache"><la:message
|
||||
<c:if test="${doc.has_cache=='true'}">
|
||||
<la:link href="/cache/?docId=${doc.doc_id}${appendHighlightParams}" class="cache"><la:message
|
||||
key="labels.search_result_cache" /></la:link>
|
||||
</c:if>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue