Here is what I found:

You can't access any fields that is object or nested type through doc[...]
notation unfortunately:

 ... snip.., that the doc[...] notation only allows for simple valued fields
(can’t return a json object from it) and makes sense only on non-analyzed or
single term based fields.
Reference:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html

So, one possible way I found was to access via _source. My data structure
was nested array of objects with name and value properties:
"aggs": {
    "test": {
      "sum": {
        "script": "if(_source.containsKey("field_name")){for(e :
_source["field_name"]){ ... }};..."

One caveat is that it is very slow compared to accessing via doc...
In my project, it was not a show stopper, but let me know if someone figures
out a better way to handle this situation. 
Thanks!




--
View this message in context: 
http://elasticsearch-users.115913.n3.nabble.com/Using-a-nested-object-property-within-custom-filters-score-script-tp4046901p4065157.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1413855234562-4065157.post%40n3.nabble.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to