diff --git a/src/main/java/org/codelibs/fess/es/client/FessEsClient.java b/src/main/java/org/codelibs/fess/es/client/FessEsClient.java index 299ffcf97..43435043e 100644 --- a/src/main/java/org/codelibs/fess/es/client/FessEsClient.java +++ b/src/main/java/org/codelibs/fess/es/client/FessEsClient.java @@ -683,11 +683,10 @@ public class FessEsClient implements Client { final SearchRequestBuilder searchRequestBuilder = client.prepareSearch(index).setTypes(type); if (condition.build(searchRequestBuilder)) { - if (ComponentUtil.hasQueryHelper()) { - final QueryHelper queryHelper = ComponentUtil.getQueryHelper(); - if (queryHelper.getTimeAllowed() >= 0) { - searchRequestBuilder.setTimeout(TimeValue.timeValueMillis(queryHelper.getTimeAllowed())); - } + final FessConfig fessConfig = ComponentUtil.getFessConfig(); + final long queryTimeout = fessConfig.getQueryTimeoutAsInteger().longValue(); + if (queryTimeout >= 0) { + searchRequestBuilder.setTimeout(TimeValue.timeValueMillis(queryTimeout)); } try { diff --git a/src/main/java/org/codelibs/fess/helper/QueryHelper.java b/src/main/java/org/codelibs/fess/helper/QueryHelper.java index 489509d3a..eb417c708 100644 --- a/src/main/java/org/codelibs/fess/helper/QueryHelper.java +++ b/src/main/java/org/codelibs/fess/helper/QueryHelper.java @@ -115,8 +115,6 @@ public class QueryHelper { protected boolean lowercaseWildcard = true; - protected long timeAllowed = -1; - protected SortBuilder[] defaultSortBuilders; protected String highlightPrefix = "hl_"; @@ -751,20 +749,6 @@ public class QueryHelper { this.additionalQuery = additionalQuery; } - /** - * @return the timeAllowed - */ - public long getTimeAllowed() { - return timeAllowed; - } - - /** - * @param timeAllowed the timeAllowed to set - */ - public void setTimeAllowed(final long timeAllowed) { - this.timeAllowed = timeAllowed; - } - public void addDefaultSort(final String fieldName, final String order) { final List> list = new ArrayList<>(); if (defaultSortBuilders != null) { diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index 12e97e532..6f81889ae 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -474,6 +474,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. 1000 */ String QUERY_MAX_LENGTH = "query.max.length"; + /** The key of the configuration. e.g. 10000 */ + String QUERY_TIMEOUT = "query.timeout"; + /** The key of the configuration. e.g. location */ String QUERY_GEO_FIELDS = "query.geo.fields"; @@ -2626,6 +2629,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ Integer getQueryMaxLengthAsInteger(); + /** + * Get the value for the key 'query.timeout'.
+ * The value is, e.g. 10000
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryTimeout(); + + /** + * Get the value for the key 'query.timeout' as {@link Integer}.
+ * The value is, e.g. 10000
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryTimeoutAsInteger(); + /** * Get the value for the key 'query.geo.fields'.
* The value is, e.g. location
@@ -5939,6 +5957,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction return getAsInteger(FessConfig.QUERY_MAX_LENGTH); } + public String getQueryTimeout() { + return get(FessConfig.QUERY_TIMEOUT); + } + + public Integer getQueryTimeoutAsInteger() { + return getAsInteger(FessConfig.QUERY_TIMEOUT); + } + public String getQueryGeoFields() { return get(FessConfig.QUERY_GEO_FIELDS); } diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index 4c3ed66e7..a5136d78b 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -221,6 +221,7 @@ index.indices.timeout=1m # query query.max.length=1000 +query.timeout=10000 query.geo.fields=location query.browser.lang.parameter.name=browser_lang query.replace.term.with.prefix.query=true