【发布时间】:2015-08-14 09:43:41
【问题描述】:
寻找指针以了解如何使用 java api 调用 Groovy 脚本。
test.groovy
def value = dynamicValue
return value
想用 Java 翻译以下查询:
GET /test-index/_search
{
"query": {
"match_all": {}
},
"script_fields": {
"checkValue": {
"script": "test",
"params": {
"dynamicValue": 7
}
}
}
}
【问题讨论】:
-
我必须警告,确保您的 ES-cluster 不能从外部调用(我突然关闭,并且中国鸡在我的 ES 中栖息)都从 HTTP 作为传输
-
@Danielson:当我有数据要使用 java-api 进行索引时,我正在调用 ES 运行,完成后我正在搜索它,在一种情况下,我需要根据一些用 groovy 编写的条件放在 ES 目录中。在这种情况下,如何从外部调用 ES-cluster ?我没有得到正确的,你能解释一下吗?
-
首先,如果你的版本是 >
v1.4.3并且你还没有将script.groovy.sandbox.enabled: false更改为script.groovy.sandbox.enabled: true,那么请忽略我!否则,您需要检查您是否可以通过your_external_ip_address:9200访问您的集群(您应该不会得到响应)。尝试从远处的计算机以Node的身份连接到您的集群,您一定无法访问,请尝试使用Client CLIENT = new TransportClient(ImmutableSettings.settingsBuilder().put("cluster.name", "your_name").build()).addTransportAddress(new InetSocketTransportAddress("external_ip", 9300));。 -
根据
elastic.co链接:If you are running a vulnerable version of Elasticsearch, you should either upgrade to at least v1.3.8 or v1.4.3, or disable dynamic Groovy scripts by adding this setting to the config/elasticsearch.yml file in all nodes in the cluster:script.groovy.sandbox.enabled: false如您所说。所以根据ES,你很好......
标签: java groovy elasticsearch elasticsearch-java-api