fix #1628 add score and view fields
This commit is contained in:
parent
a29b40f03d
commit
ee42b1bd55
2 changed files with 23 additions and 12 deletions
|
@ -35,6 +35,8 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final Boolean F = false;
|
||||
|
||||
public static final String SCORE = "score";
|
||||
|
||||
public static final String ON = "on";
|
||||
|
||||
public static final String READY = "ready";
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package org.codelibs.fess.app.service;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -43,6 +42,7 @@ import org.codelibs.fess.es.client.FessEsClient.SearchConditionBuilder;
|
|||
import org.codelibs.fess.es.client.FessEsClientException;
|
||||
import org.codelibs.fess.helper.QueryHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.helper.ViewHelper;
|
||||
import org.codelibs.fess.mylasta.action.FessUserBean;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
@ -198,23 +198,32 @@ public class SearchService {
|
|||
.responseFields(queryHelper.getScrollResponseFields()).searchRequestType(params.getType()).build();
|
||||
},
|
||||
(searchResponse, hit) -> {
|
||||
final Map<String, Object> docMap = new HashMap<>();
|
||||
final Map<String, Object> source = hit.getSourceAsMap();
|
||||
if (source != null) {
|
||||
final Map<String, Object> docMap = new HashMap<>(source);
|
||||
docMap.put(fessConfig.getIndexFieldId(), hit.getId());
|
||||
docMap.put(fessConfig.getIndexFieldVersion(), hit.getVersion());
|
||||
return docMap;
|
||||
docMap.putAll(source);
|
||||
}
|
||||
final Map<String, DocumentField> fields = hit.getFields();
|
||||
if (fields != null) {
|
||||
final Map<String, Object> docMap =
|
||||
fields.entrySet().stream()
|
||||
.collect(Collectors.toMap(e -> e.getKey(), e -> (Object) e.getValue().getValues()));
|
||||
docMap.put(fessConfig.getIndexFieldId(), hit.getId());
|
||||
docMap.put(fessConfig.getIndexFieldVersion(), hit.getVersion());
|
||||
return docMap;
|
||||
docMap.putAll(fields.entrySet().stream()
|
||||
.collect(Collectors.toMap(e -> e.getKey(), e -> (Object) e.getValue().getValues())));
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
|
||||
final ViewHelper viewHelper = ComponentUtil.getViewHelper();
|
||||
if (viewHelper != null && !docMap.isEmpty()) {
|
||||
docMap.put(fessConfig.getResponseFieldContentTitle(), viewHelper.getContentTitle(docMap));
|
||||
docMap.put(fessConfig.getResponseFieldContentDescription(), viewHelper.getContentDescription(docMap));
|
||||
docMap.put(fessConfig.getResponseFieldUrlLink(), viewHelper.getUrlLink(docMap));
|
||||
docMap.put(fessConfig.getResponseFieldSitePath(), viewHelper.getSitePath(docMap));
|
||||
}
|
||||
|
||||
if (!docMap.containsKey(Constants.SCORE)) {
|
||||
docMap.put(Constants.SCORE, hit.getScore());
|
||||
}
|
||||
|
||||
docMap.put(fessConfig.getIndexFieldId(), hit.getId());
|
||||
docMap.put(fessConfig.getIndexFieldVersion(), hit.getVersion());
|
||||
return docMap;
|
||||
}, cursor);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue