本文整理汇总了Java中org.elasticsearch.script.ScriptType.STORED属性的典型用法代码示例。如果您正苦于以下问题:Java ScriptType.STORED属性的具体用法?Java ScriptType.STORED怎么用?Java ScriptType.STORED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.elasticsearch.script.ScriptType
的用法示例。
在下文中一共展示了ScriptType.STORED属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: randomScript
private Script randomScript(String script) {
if (randomBoolean()) {
return new Script(script);
} else {
ScriptType type = randomFrom(ScriptType.values());
return new Script(
type, type == ScriptType.STORED ? null : randomFrom("my_lang", Script.DEFAULT_SCRIPT_LANG), script, Collections.emptyMap());
}
}
示例2: testStoredScript
public void testStoredScript() {
assertAcked(client().admin().cluster().preparePutStoredScript()
.setId("my_script")
.setLang(CustomScriptPlugin.NAME)
// Source is not interpreted but my_script is defined in CustomScriptPlugin
.setContent(new BytesArray("{ \"script\": \"Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)\" }"),
XContentType.JSON));
Script script = new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "my_script", Collections.emptyMap());
SearchResponse response = client()
.prepareSearch("idx")
.addAggregation(
histogram("histo")
.field(FIELD_1_NAME)
.interval(interval)
.subAggregation(sum("field2Sum").field(FIELD_2_NAME))
.subAggregation(sum("field3Sum").field(FIELD_3_NAME))
.subAggregation(bucketSelector("bucketSelector", script, "field2Sum", "field3Sum")))
.execute().actionGet();
assertSearchResponse(response);
Histogram histo = response.getAggregations().get("histo");
assertThat(histo, notNullValue());
assertThat(histo.getName(), equalTo("histo"));
List<? extends Bucket> buckets = histo.getBuckets();
for (int i = 0; i < buckets.size(); ++i) {
Histogram.Bucket bucket = buckets.get(i);
Sum field2Sum = bucket.getAggregations().get("field2Sum");
assertThat(field2Sum, notNullValue());
double field2SumValue = field2Sum.getValue();
Sum field3Sum = bucket.getAggregations().get("field3Sum");
assertThat(field3Sum, notNullValue());
double field3SumValue = field3Sum.getValue();
assertThat(field2SumValue + field3SumValue, greaterThan(100.0));
}
}
示例3: randomScript
static SearchSourceBuilder.ScriptField randomScript() {
ScriptType randomScriptType = randomFrom(ScriptType.values());
Map<String, Object> randomMap = new HashMap<>();
if (randomBoolean()) {
int numEntries = randomIntBetween(0, 32);
for (int i = 0; i < numEntries; i++) {
randomMap.put(String.valueOf(i), randomAsciiOfLength(16));
}
}
Script script = new Script(randomScriptType, randomScriptType == ScriptType.STORED ? null : randomAsciiOfLengthBetween(1, 4),
randomAsciiOfLength(128), randomMap);
return new SearchSourceBuilder.ScriptField(randomAsciiOfLengthBetween(1, 32), script, randomBoolean());
}
示例4: parseAndUpdateScriptType
private void parseAndUpdateScriptType(String scriptType) {
String scriptTypeUpper = scriptType.toUpperCase();
switch(scriptTypeUpper){
case "INLINE":
this.scriptType = ScriptType.INLINE;
break;
case "INDEXED":
case "STORED":
this.scriptType = ScriptType.STORED;
break;
case "FILE":
this.scriptType = ScriptType.FILE;
break;
}
}