Grandparents aggregations NullPointer

I am using Elasticsearch 1.4.4.

I am defining a parent-child index with three levels (grandparents)
following the instructions in the document:
https://www.elastic.co/guide/en/elasticsearch/guide/current/grandparents.html

My structure is
Continent -> Country -> Region

MAPPING

I create an index with the following mapping:

curl -XPOST 'localhost:9200/geo' -d'
{
"mappings": {
"continent": {},
"country": {
"_parent": {
"type": "continent"
}
},
"region": {
"_parent": {
"type": "country"
}
}
}
}'

INDEXING

I index three entities:

curl -XPOST 'localhost:9200/geo/continent/europe' -d'
{
"name":"Europe"
}'

curl -XPOST 'localhost:9200/geo/country/italy?parent=europe' -d'
{
"name":"Italy"
}'

curl -XPOST
'localhost:9200/geo/region/lombardy?parent=italy&routing=europe' -d'
{
"name":"Lombardia"
}'

QUERY THAT WORKS

If I query and aggregate according to the document everything works fine:

curl -XGET 'localhost:9200/geo/continent/_search?pretty=true' -d '
{
"query": {
"has_child": {
"type": "country",
"query": {
"has_child": {
"type": "region",
"query": {
"match": {
"name": "Lombardia"
}
}
}
}
}
},
"aggs": {
"country": {
"terms": {
"field": "name"
},
"aggs": {
"countries": {
"children": {
"type": "country"
},
"aggs": {
"country_names" : {
"terms" : {
"field" : "country.name"
}
}
}
}
}
}
}
}'

QUERY THAT DOES NOT WORK

However, if I try with multi-level aggregations like in:

curl -XGET 'localhost:9200/geo/continent/_search?pretty=true' -d '
{
"query": {
"has_child": {
"type": "country",
"query": {
"has_child": {
"type": "region",
"query": {
"match": {
"name": "Lombardia"
}
}
}
}
}
},
"aggs": {
"continent_names": {
"terms": {
"field": "name"
},
"aggs": {
"countries": {
"children": {
"type": "country"
},
"aggs": {
"regions": {
"children": {
"type": "region"
},
"aggs": {
"region_names" : {
"terms" : {
"field" : "region.name"
}
}
}
}
}
}
}
}
}
}'

I get back the following

{

"error" : "SearchPhaseExecutionException[Failed to execute phase [query],
all shards failed; shardFailures {[b5CbW5byQdSSW-rIwta0rA][geo][0]:
QueryPhaseExecutionException[[geo][0]:
query[filtered(child_filter[country/continent](filtered(child_filterregion/country)->cache(_type:country)))->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][1]: QueryPhaseExecutionException[[geo][1]:
query[filtered(child_filter[country/continent](filtered(child_filterregion/country)->cache(_type:country)))->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][2]: QueryPhaseExecutionException[[geo][2]:
query[filtered(child_filter[country/continent](filtered(child_filterregion/country)->cache(_type:country)))->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][3]: QueryPhaseExecutionException[[geo][3]:
query[filtered(child_filter[country/continent](filtered(child_filterregion/country)->cache(_type:country)))->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][4]: QueryPhaseExecutionException[[geo][4]:
query[filtered(child_filter[country/continent](filtered(child_filterregion/country)->cache(_type:country)))->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}]",

"status" : 500

}

The 'grandparents' document says: "Querying and aggregating across
generations works, as long as you step through each generation."

How do I get the last query and aggregation to work across all three levels
of the index?

What am I missing?

Thank you,
Paolo

--
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/f4426a7b-124e-450e-98c0-cc43cf7f9c6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I've posted the issue here:

On Wednesday, March 11, 2015 at 4:42:27 PM UTC-4, Paolo Ciccarese wrote:

I am using Elasticsearch 1.4.4.

I am defining a parent-child index with three levels (grandparents)
following the instructions in the document:

Grandparents and Grandchildren | Elasticsearch: The Definitive Guide [2.x] | Elastic

My structure is
Continent -> Country -> Region

MAPPING

I create an index with the following mapping:

curl -XPOST 'localhost:9200/geo' -d'
{
"mappings": {
"continent": {},
"country": {
"_parent": {
"type": "continent"
}
},
"region": {
"_parent": {
"type": "country"
}
}
}
}'

INDEXING

I index three entities:

curl -XPOST 'localhost:9200/geo/continent/europe' -d'
{
"name":"Europe"
}'

curl -XPOST 'localhost:9200/geo/country/italy?parent=europe' -d'
{
"name":"Italy"
}'

curl -XPOST
'localhost:9200/geo/region/lombardy?parent=italy&routing=europe' -d'
{
"name":"Lombardia"
}'

QUERY THAT WORKS

If I query and aggregate according to the document everything works fine:

curl -XGET 'localhost:9200/geo/continent/_search?pretty=true' -d '
{
"query": {
"has_child": {
"type": "country",
"query": {
"has_child": {
"type": "region",
"query": {
"match": {
"name": "Lombardia"
}
}
}
}
}
},
"aggs": {
"country": {
"terms": {
"field": "name"
},
"aggs": {
"countries": {
"children": {
"type": "country"
},
"aggs": {
"country_names" : {
"terms" : {
"field" : "country.name"
}
}
}
}
}
}
}
}'

QUERY THAT DOES NOT WORK

However, if I try with multi-level aggregations like in:

curl -XGET 'localhost:9200/geo/continent/_search?pretty=true' -d '
{
"query": {
"has_child": {
"type": "country",
"query": {
"has_child": {
"type": "region",
"query": {
"match": {
"name": "Lombardia"
}
}
}
}
}
},
"aggs": {
"continent_names": {
"terms": {
"field": "name"
},
"aggs": {
"countries": {
"children": {
"type": "country"
},
"aggs": {
"regions": {
"children": {
"type": "region"
},
"aggs": {
"region_names" : {
"terms" : {
"field" : "region.name"
}
}
}
}
}
}
}
}
}
}'

I get back the following

{

"error" : "SearchPhaseExecutionException[Failed to execute phase
[query], all shards failed; shardFailures
{[b5CbW5byQdSSW-rIwta0rA][geo][0]: QueryPhaseExecutionException[[geo][0]:
query[filtered(child_filtercountry/continent)->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][1]: QueryPhaseExecutionException[[geo][1]:
query[filtered(child_filtercountry/continent)->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][2]: QueryPhaseExecutionException[[geo][2]:
query[filtered(child_filtercountry/continent)->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][3]: QueryPhaseExecutionException[[geo][3]:
query[filtered(child_filtercountry/continent)->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}{[b5CbW5byQdSSW-rIwta0rA][geo][4]: QueryPhaseExecutionException[[geo][4]:
query[filtered(child_filtercountry/continent)->cache(_type:continent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}]",

"status" : 500

}

The 'grandparents' document says: "Querying and aggregating across
generations works, as long as you step through each generation."

How do I get the last query and aggregation to work across all three
levels of the index?

What am I missing?

Thank you,
Paolo

--
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/0cbdfb5e-ad20-4820-aac9-48c837976fd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.