use of org.codelibs.fess.entity.FacetQueryView in project fess by codelibs.
the class ViewHelperTest method test_facetQueries.
public void test_facetQueries() {
final List<FacetQueryView> list = viewHelper.getFacetQueryViewList();
assertEquals(3, list.size());
FacetQueryView view1 = list.get(0);
assertEquals("labels.facet_timestamp_title", view1.getTitle());
assertEquals(4, view1.getQueryMap().size());
FacetQueryView view2 = list.get(1);
assertEquals("labels.facet_contentLength_title", view2.getTitle());
assertEquals(5, view2.getQueryMap().size());
FacetQueryView view3 = list.get(2);
assertEquals("labels.facet_filetype_title", view3.getTitle());
assertEquals(10, view3.getQueryMap().size());
}
use of org.codelibs.fess.entity.FacetQueryView in project fess by codelibs.
the class ViewHelper method init.
@PostConstruct
public void init() {
if (logger.isDebugEnabled()) {
logger.debug("Initialize {}", this.getClass().getSimpleName());
}
final FessConfig fessConfig = ComponentUtil.getFessConfig();
escapedHighlightPre = LaFunctions.h(originalHighlightTagPre);
escapedHighlightPost = LaFunctions.h(originalHighlightTagPost);
highlightTagPre = fessConfig.getQueryHighlightTagPre();
highlightTagPost = fessConfig.getQueryHighlightTagPost();
highlightedFields = fessConfig.getQueryHighlightContentDescriptionFieldsAsArray();
for (final int v : fessConfig.getQueryHighlightTerminalCharsAsArray()) {
highlightTerminalCharSet.add(v);
}
try {
final ServletContext servletContext = ComponentUtil.getComponent(ServletContext.class);
servletContext.setSessionTrackingModes(fessConfig.getSessionTrackingModesAsSet().stream().map(SessionTrackingMode::valueOf).collect(Collectors.toSet()));
} catch (final Throwable t) {
logger.warn("Failed to set SessionTrackingMode.", t);
}
split(fessConfig.getQueryFacetQueries(), "\n").of(stream -> stream.map(String::trim).filter(StringUtil::isNotEmpty).forEach(s -> {
final String[] values = StringUtils.split(s, ":", 2);
if (values.length != 2) {
return;
}
final FacetQueryView facetQueryView = new FacetQueryView();
facetQueryView.setTitle(values[0]);
split(values[1], "\t").of(subStream -> subStream.map(String::trim).filter(StringUtil::isNotEmpty).forEach(v -> {
final String[] facet = StringUtils.split(v, "=", 2);
if (facet.length == 2) {
facetQueryView.addQuery(facet[0], facet[1]);
}
}));
facetQueryView.init();
facetQueryViewList.add(facetQueryView);
if (logger.isDebugEnabled()) {
logger.debug("loaded {}", facetQueryView);
}
}));
facetCache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(facetCacheDuration, TimeUnit.SECONDS).build();
textFragmentPrefixLength = fessConfig.getQueryHighlightTextFragmentPrefixLengthAsInteger();
textFragmentSuffixLength = fessConfig.getQueryHighlightTextFragmentSuffixLengthAsInteger();
textFragmentSize = fessConfig.getQueryHighlightTextFragmentSizeAsInteger();
}
Aggregations