KIbana 4 scripted-metric-aggregation

Hi @ All

First of all, Kibana 4 beta looks very nice, great work!

I'm trying to use the experimental groovy code scripting engine

What i try:

curl -XPOST 'http://localhost:9200/info/_search' -d '{
"query": {
"match_all" : {}
},
"aggs": {
"result": {
"scripted_metric": {
"init_script" : "_agg['res'] = []",
"map_script" : "{ _agg.res.add( doc['checkoutAmount'] ? :
0) }"
}
}
}
}'

What i get

{"error":"SearchPhaseExecutionException[Failed to execute phase [query],
all shards failed; shardFailures {[GlMPEwZFTbONlt0MdqqQIQ][sessioninfo][0]:
GroovyScriptExecutionException[MissingPropertyException[No such property:
res for class: Script32]]}{[GlMPEwZFTbONlt0MdqqQIQ][sessioninfo][1]:
GroovyScriptExecutionException[MissingPropertyException[No such property:
res for class: Script31]]}{[GlMPEwZFTbONlt0MdqqQIQ][sessioninfo][2]:
GroovyScriptExecutionException[MissingPropertyException[No such property:
res for class: Script33]]}{[GlMPEwZFTbONlt0MdqqQIQ][sessioninfo][3]:
GroovyScriptExecutionException[MissingPropertyException[No such property:
res for class: Script34]]}{[GlMPEwZFTbONlt0MdqqQIQ][sessioninfo][4]:
GroovyScriptExecutionException[MissingPropertyException[No such property:
res for class: Script35]]}]","status":400}

i think it went something wrong in the "init_script" line.

Anyone a hint what i do wrong?

Ivan

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7081fb00-40aa-4a0c-b5fb-f9e36bf494ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Got the solution.

The Problem is that groovy code is implemented as a closure so you should
do it this way:
"scripted_metric": {
"init_script" : "{_agg -> _agg['res'] = []}",
"map_script" : "{_agg -> _agg.res.add(
doc['checkoutAmount'] ?: 0) }"
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/69cc3db4-c9db-489e-a0db-643a526d1c00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.