fix #976 add browser_lang
This commit is contained in:
parent
8805206256
commit
32110442d5
3 changed files with 32 additions and 1 deletions
|
@ -426,6 +426,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. location */
|
||||
String QUERY_GEO_FIELDS = "query.geo.fields";
|
||||
|
||||
/** The key of the configuration. e.g. browser_lang */
|
||||
String QUERY_BROWSER_LANG_PARAMETER_NAME = "query.browser.lang.parameter.name";
|
||||
|
||||
/** The key of the configuration. e.g. true */
|
||||
String QUERY_REPLACE_TERM_WITH_PREFIX_QUERY = "query.replace.term.with.prefix.query";
|
||||
|
||||
|
@ -2282,6 +2285,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
String getQueryGeoFields();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.browser.lang.parameter.name'. <br>
|
||||
* The value is, e.g. browser_lang <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryBrowserLangParameterName();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.replace.term.with.prefix.query'. <br>
|
||||
* The value is, e.g. true <br>
|
||||
|
@ -5044,6 +5054,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return get(FessConfig.QUERY_GEO_FIELDS);
|
||||
}
|
||||
|
||||
public String getQueryBrowserLangParameterName() {
|
||||
return get(FessConfig.QUERY_BROWSER_LANG_PARAMETER_NAME);
|
||||
}
|
||||
|
||||
public String getQueryReplaceTermWithPrefixQuery() {
|
||||
return get(FessConfig.QUERY_REPLACE_TERM_WITH_PREFIX_QUERY);
|
||||
}
|
||||
|
|
|
@ -17,17 +17,24 @@ package org.codelibs.fess.mylasta.direction.sponsor;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.LocaleUtils;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.optional.OptionalObject;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
import org.dbflute.util.DfTypeUtil;
|
||||
import org.lastaflute.web.ruts.process.ActionRuntime;
|
||||
import org.lastaflute.web.servlet.request.RequestManager;
|
||||
import org.lastaflute.web.servlet.request.UserLocaleProcessProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author jflute
|
||||
*/
|
||||
public class FessUserLocaleProcessProvider implements UserLocaleProcessProvider {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FessUserLocaleProcessProvider.class);
|
||||
|
||||
@Override
|
||||
public boolean isAcceptCookieLocale() {
|
||||
|
@ -36,7 +43,16 @@ public class FessUserLocaleProcessProvider implements UserLocaleProcessProvider
|
|||
|
||||
@Override
|
||||
public OptionalThing<Locale> findBusinessLocale(final ActionRuntime runtimeMeta, final RequestManager requestManager) {
|
||||
return OptionalObject.empty(); // to next determination
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String name = fessConfig.getQueryBrowserLangParameterName();
|
||||
if (StringUtil.isNotBlank(name)) {
|
||||
try {
|
||||
return requestManager.getParameter(name).filter(StringUtil::isNotBlank).map(LocaleUtils::toLocale);
|
||||
} catch (Exception e) {
|
||||
logger.debug("Failed to parse a value of " + name + ".", e);
|
||||
}
|
||||
}
|
||||
return OptionalObject.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -202,6 +202,7 @@ index.indices.timeout=1m
|
|||
# query
|
||||
query.max.length=1000
|
||||
query.geo.fields=location
|
||||
query.browser.lang.parameter.name=browser_lang
|
||||
query.replace.term.with.prefix.query=true
|
||||
query.highlight.fragment.size=100
|
||||
query.max.search.result.offset=100000
|
||||
|
|
Loading…
Add table
Reference in a new issue