SOLR-12553: Check local params in SignificantTerms Query Parser

This commit is contained in:
Alexandre Rafalovitch 2018-07-19 22:12:22 -04:00
parent 9d3cc1e16f
commit f6e9d00b90
2 changed files with 12 additions and 4 deletions

View File

@ -157,6 +157,8 @@ Bug Fixes
* SOLR-12343: Fixed a bug in JSON Faceting that could cause incorrect counts/stats when using non default
sort options. This also adds a new configurable "overrefine" option. (Yonik Seeley, hossman)
* SOLR-12553: Allow SignificantTerms Query Parser to use local parameters (Alexandre Rafalovitch)
Optimizations
----------------------

View File

@ -55,12 +55,18 @@ public class SignificantTermsQParserPlugin extends QParserPlugin {
@Override
public Query parse() throws SyntaxError {
String field = getParam("field");
int numTerms = Integer.parseInt(params.get("numTerms", "20"));
float minDocs = Float.parseFloat(params.get("minDocFreq", "5"));
float maxDocs = Float.parseFloat(params.get("maxDocFreq", ".3"));
int minTermLength = Integer.parseInt(params.get("minTermLength", "4"));
int numTerms = Integer.parseInt(getParamWithDefault("numTerms", "20"));
float minDocs = Float.parseFloat(getParamWithDefault("minDocFreq", "5"));
float maxDocs = Float.parseFloat(getParamWithDefault("maxDocFreq", ".3"));
int minTermLength = Integer.parseInt(getParamWithDefault("minTermLength", "4"));
return new SignificantTermsQuery(field, numTerms, minDocs, maxDocs, minTermLength);
}
private String getParamWithDefault(String paramName, String defaultValue) {
String result = getParam(paramName);
return (result != null)? result: defaultValue;
}
}
private static class SignificantTermsQuery extends AnalyticsQuery {