Nested object scripting

Hi everyone,

I need to know how to make a facet script for a nested object.

The mapping:

{
"vehicle": {
"properties": {
"id": {
"type": "long"
},
"fitments": {
"type": "nested",
"properties": {
"dimensions": {
"type": "nested",
"properties": {
"id": {
"type": "long"
},
"position": {
"type": "string",
"index_analyzer": "string_lowercase"
}
}
}
},
"id": {
"type": "long"
}
}
}
}
}

I've tried:
Query:
{
...
"facets" : {
"size" : {
"terms" : {
"size" : 15,
"order" : "term",
"all_terms" : false,
"script" : "_source.fitments.dimensions.id + ';' +
_source.fitments.dimensions.position"
},
"nested" : "fitments.dimensions"
}
}
}

Response:
QueryPhaseExecutionException[[en_us][3]: query[filtered(+(year:[1983 TO
1983]) +(carMaker:audi) +(carSegment:4000)
+(carType:base))->cache(_type:vehicle)],from[0],size[0]: Query Failed
[Failed to execute main query]]; nested: PropertyAccessException[[Error:
could not access: fitments; in class:
org.elasticsearch.search.lookup.SourceLookup]\n[Near : {...
_source.fitments.dimensions.id ....}]\n ^\n[Line: 1, Column:
1]];

I've tried also:

Query:
{
...
"facets" : {
"size" : {
"terms" : {
"size" : 15,
"order" : "term",
"all_terms" : false,
"script" : "doc['fitments.dimensions.id'] + ';' +
doc['fitments.dimensions.position']"
},
"nested" : "fitments.dimensions"
}
}
}

Response:
"facets": {
"size": {
"_type": "terms",
"missing": 0,
"total": 2,
"other": 0,
"terms": [
{
"term":
"org.elasticsearch.index.fielddata.ScriptDocValues$Longs@1b3562af;org.elasticsearch.index.fielddata.ScriptDocValues$Strings@4de1dd1d",
"count": 2
}
]
}
}

Thank you in advance for your help guys :slight_smile:

--
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/d735a13a-861c-4d6d-a54d-477be4291e98%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.