fix #1189 add query.timeout
This commit is contained in:
parent
f551831d04
commit
f3a253f2b3
4 changed files with 32 additions and 21 deletions
|
@ -695,11 +695,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 {
|
||||
|
|
|
@ -115,8 +115,6 @@ public class QueryHelper {
|
|||
|
||||
protected boolean lowercaseWildcard = true;
|
||||
|
||||
protected long timeAllowed = -1;
|
||||
|
||||
protected SortBuilder<?>[] defaultSortBuilders;
|
||||
|
||||
protected String highlightPrefix = "hl_";
|
||||
|
@ -768,20 +766,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<SortBuilder<?>> list = new ArrayList<>();
|
||||
if (defaultSortBuilders != null) {
|
||||
|
|
|
@ -477,6 +477,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";
|
||||
|
||||
|
@ -2648,6 +2651,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
Integer getQueryMaxLengthAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.timeout'. <br>
|
||||
* The value is, e.g. 10000 <br>
|
||||
* @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}. <br>
|
||||
* The value is, e.g. 10000 <br>
|
||||
* @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'. <br>
|
||||
* The value is, e.g. location <br>
|
||||
|
@ -6009,6 +6027,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);
|
||||
}
|
||||
|
@ -7551,6 +7577,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
defaultMap.put(FessConfig.INDEX_HEALTH_TIMEOUT, "10m");
|
||||
defaultMap.put(FessConfig.INDEX_INDICES_TIMEOUT, "1m");
|
||||
defaultMap.put(FessConfig.QUERY_MAX_LENGTH, "1000");
|
||||
defaultMap.put(FessConfig.QUERY_TIMEOUT, "10000");
|
||||
defaultMap.put(FessConfig.QUERY_GEO_FIELDS, "location");
|
||||
defaultMap.put(FessConfig.QUERY_BROWSER_LANG_PARAMETER_NAME, "browser_lang");
|
||||
defaultMap.put(FessConfig.QUERY_REPLACE_TERM_WITH_PREFIX_QUERY, "true");
|
||||
|
|
|
@ -222,6 +222,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
|
||||
|
|
Loading…
Add table
Reference in a new issue