当前位置: 首页>>代码示例>>Java>>正文


Java ScriptType.STORED属性代码示例

本文整理汇总了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());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:ScriptedMetricTests.java

示例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));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:39,代码来源:BucketSelectorIT.java

示例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());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:InnerHitBuilderTests.java

示例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;
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:15,代码来源:ScriptFilter.java


注:本文中的org.elasticsearch.script.ScriptType.STORED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。