看来您正在使用
mvel脚本。您只需要指定要使用的名称即可
groovy。
{"size": 0,"aggs": {"count": { "terms": { "script": "doc.billingSequence.value as Integer", "order": { "_term": "asc" }, "value_type": "integer", "size": 10, "lang": "groovy" <--- add this line }}}}还要确保将其包括在项目依赖项中,因为默认情况下不包括此项:
<dependency> <groupId>org.prehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>2.4.0</version> <scope>compile</scope> <optional>true</optional> </dependency>
更新
如果您确实不能使用Groovy,则可以坚持使用MVEL并使用MVEL类型转换:
{"size": 0,"aggs": {"count": { "terms": { "script": "Integer.parseInt(doc.billingSequence.value)", <--- change this line "order": { "_term": "asc" }, "value_type": "integer", "size": 10 }}}}


