[significant terms] Use 'script_file' instead of 'script' if the script is a file
This commit is contained in:
parent
580728dfd6
commit
3abf11611b
|
@ -189,11 +189,17 @@ public class ScriptHeuristic extends SignificanceHeuristic {
|
|||
private String lang = null;
|
||||
private Map<String, Object> params = null;
|
||||
private String scriptId;
|
||||
private String scriptFile;
|
||||
public ScriptHeuristicBuilder setScript(String script) {
|
||||
this.script = script;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScriptHeuristicBuilder setScriptFile(String script) {
|
||||
this.scriptFile = script;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScriptHeuristicBuilder setLang(String lang) {
|
||||
this.lang = lang;
|
||||
return this;
|
||||
|
@ -224,6 +230,9 @@ public class ScriptHeuristic extends SignificanceHeuristic {
|
|||
if (scriptId != null) {
|
||||
builder.field("script_id", scriptId);
|
||||
}
|
||||
if (scriptFile != null) {
|
||||
builder.field("script_file", scriptFile);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ public class SignificantTermsSignificanceScoreTests extends ElasticsearchIntegra
|
|||
return settingsBuilder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("plugin.types", CustomSignificanceHeuristicPlugin.class.getName())
|
||||
.put("path.conf", this.getResourcePath("config"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -527,6 +528,7 @@ public class SignificantTermsSignificanceScoreTests extends ElasticsearchIntegra
|
|||
String script = null;
|
||||
String lang = null;
|
||||
String scriptId = null;
|
||||
String scriptFile = null;
|
||||
if (randomBoolean()) {
|
||||
params = new HashMap<>();
|
||||
params.put("param", randomIntBetween(1, 100));
|
||||
|
@ -561,9 +563,9 @@ public class SignificantTermsSignificanceScoreTests extends ElasticsearchIntegra
|
|||
}
|
||||
case 2: {
|
||||
if (params == null) {
|
||||
script = "significance_script_no_params";
|
||||
scriptFile = "significance_script_no_params";
|
||||
} else {
|
||||
script = "significance_script_with_params";
|
||||
scriptFile = "significance_script_with_params";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -580,7 +582,7 @@ public class SignificantTermsSignificanceScoreTests extends ElasticsearchIntegra
|
|||
break;
|
||||
}
|
||||
}
|
||||
ScriptHeuristic.ScriptHeuristicBuilder builder = new ScriptHeuristic.ScriptHeuristicBuilder().setScript(script).setLang(lang).setParams(params).setScriptId(scriptId);
|
||||
ScriptHeuristic.ScriptHeuristicBuilder builder = new ScriptHeuristic.ScriptHeuristicBuilder().setScript(script).setLang(lang).setParams(params).setScriptId(scriptId).setScriptFile(scriptFile);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue