Search in sources :

Example 1 with FacetQueryView

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());
}
Also used : FacetQueryView(org.codelibs.fess.entity.FacetQueryView)

Example 2 with FacetQueryView

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();
}
Also used : Constants(org.codelibs.fess.Constants) BufferedInputStream(java.io.BufferedInputStream) URLDecoder(java.net.URLDecoder) Date(java.util.Date) OptionalThing(org.dbflute.optional.OptionalThing) StringUtils(org.apache.commons.lang3.StringUtils) ActionRuntime(org.lastaflute.web.ruts.process.ActionRuntime) LaResponseUtil(org.lastaflute.web.util.LaResponseUtil) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) StreamResponse(org.lastaflute.web.response.StreamResponse) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) Matcher(java.util.regex.Matcher) StreamUtil(org.codelibs.core.stream.StreamUtil) Locale(java.util.Locale) Map(java.util.Map) LaFunctions(org.lastaflute.taglib.function.LaFunctions) SearchRenderData(org.codelibs.fess.entity.SearchRenderData) HttpSession(javax.servlet.http.HttpSession) Context(com.github.jknack.handlebars.Context) FacetQueryView(org.codelibs.fess.entity.FacetQueryView) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) CoreLibConstants(org.codelibs.core.CoreLibConstants) Collectors(java.util.stream.Collectors) ActionResponse(org.lastaflute.web.response.ActionResponse) List(java.util.List) Logger(org.apache.logging.log4j.Logger) ComponentUtil(org.codelibs.fess.util.ComponentUtil) PostConstruct(javax.annotation.PostConstruct) LaServletContextUtil(org.lastaflute.web.util.LaServletContextUtil) FileTemplateLoader(com.github.jknack.handlebars.io.FileTemplateLoader) Pattern(java.util.regex.Pattern) CacheBuilder(com.google.common.cache.CacheBuilder) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ResponseData(org.codelibs.fess.crawler.entity.ResponseData) DocumentUtil(org.codelibs.fess.util.DocumentUtil) FessSystemException(org.codelibs.fess.exception.FessSystemException) HighlightField(org.opensearch.search.fetch.subphase.highlight.HighlightField) HashMap(java.util.HashMap) ClientAbortException(org.apache.catalina.connector.ClientAbortException) Function(java.util.function.Function) CrawlingConfig(org.codelibs.fess.es.config.exentity.CrawlingConfig) LaRequestUtil(org.lastaflute.web.util.LaRequestUtil) ArrayList(java.util.ArrayList) CrawlerClient(org.codelibs.fess.crawler.client.CrawlerClient) UserAgentType(org.codelibs.fess.helper.UserAgentHelper.UserAgentType) HashSet(java.util.HashSet) FessUserBean(org.codelibs.fess.mylasta.action.FessUserBean) ResourceUtil(org.codelibs.fess.util.ResourceUtil) HttpServletRequest(javax.servlet.http.HttpServletRequest) Handlebars(com.github.jknack.handlebars.Handlebars) CharUtil(org.codelibs.fess.crawler.util.CharUtil) DynamicProperties(org.codelibs.core.misc.DynamicProperties) StringUtil(org.codelibs.core.lang.StringUtil) IOException(java.io.IOException) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) FacetResponse(org.codelibs.fess.util.FacetResponse) SessionTrackingMode(javax.servlet.SessionTrackingMode) File(java.io.File) CloseableUtil(org.codelibs.core.io.CloseableUtil) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) SearchForm(org.codelibs.fess.app.web.base.SearchForm) URLEncoder(java.net.URLEncoder) FessLoginAssist(org.codelibs.fess.app.web.base.login.FessLoginAssist) ServletContext(javax.servlet.ServletContext) HighlightInfo(org.codelibs.fess.entity.HighlightInfo) SimpleDateFormat(com.ibm.icu.text.SimpleDateFormat) Cache(com.google.common.cache.Cache) LogManager(org.apache.logging.log4j.LogManager) RequestDataBuilder(org.codelibs.fess.crawler.builder.RequestDataBuilder) CrawlerClientFactory(org.codelibs.fess.crawler.client.CrawlerClientFactory) Text(org.opensearch.common.text.Text) InputStream(java.io.InputStream) Template(com.github.jknack.handlebars.Template) SessionTrackingMode(javax.servlet.SessionTrackingMode) ServletContext(javax.servlet.ServletContext) FacetQueryView(org.codelibs.fess.entity.FacetQueryView) StringUtil(org.codelibs.core.lang.StringUtil) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Context (com.github.jknack.handlebars.Context)1 Handlebars (com.github.jknack.handlebars.Handlebars)1 Template (com.github.jknack.handlebars.Template)1 FileTemplateLoader (com.github.jknack.handlebars.io.FileTemplateLoader)1 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 SimpleDateFormat (com.ibm.icu.text.SimpleDateFormat)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URLDecoder (java.net.URLDecoder)1 URLEncoder (java.net.URLEncoder)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1