# Has-child query exception

**URL:** <https://discuss.elastic.co/t/has-child-query-exception/4247>\
**Category:** Elasticsearch\
**Created:** [April 18, 2011, 9:48am UTC](https://discuss.elastic.co/t/has-child-query-exception/4247 "2011-04-18T09:48:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [April 18, 2011, 9:48am UTC](https://discuss.elastic.co/t/has-child-query-exception/4247/1 "2011-04-18T09:48:44Z")

</div>

Hi All,  
To retrieve documents in parent table i am using the "has-  
child query". I have 9 documents in child table but while querying i  
am getting only 5 documents with Exception.

I am using the elasticsearch version 15.2

curl -XGET '[http://localhost:9200/db54/metadata/\_search](http://localhost:9200/db54/metadata/_search)' -d '{ "query":  
{"has\_child" : {"type" : "childtable", "query" :{ "term" : { "field1":  
"12" } }} } }'

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":  
3,"failed":2,"fail  
ures":[{"index":"db54","shard":  
3,"reason":"QueryPhaseExecutionException[[db54][3  
]: query[ConstantScore(child\_filter[childtable/metadata]  
(filtered(field1:12)-

> FilterCacheFilterWrapper(\_type:childtable)))],from[0],size[10]: Query  
> Fa  
> iled [Failed to execute child query [filtered(\_included:status2status)-  
> FilterCa  
> cheFilterWrapper(\_type:childtable)]]]; nested: "},  
> {"index":"db54","shard":4,"reaso  
> n":"QueryPhaseExecutionException[[db54][4]:  
> query[ConstantScore(child\_filter[childtable/metadata](filtered(field1:  
> 12)-\>FilterCacheFilterWrapper(\_typ  
> e:childtable)))],from[0],size[10]: Query Failed [Failed to execute  
> child query [fi  
> ltered(field1:12)-\>FilterCacheFilterWrapper(\_type:childtable)]]]; ne  
> sted: "}]},"hits":{"total":53,"max\_score":1.0,"hits":  
> [{"\_index":"db54","\_type":"  
> metadata","\_id":"0010000013","\_score":1.0},  
> {"\_index":"db54","\_type":"metadata","  
> \_id":"0010000018","\_score":1.0},  
> {"\_index":"db54","\_type":"metadata","\_id":"00100  
> 00020","\_score":1.0},  
> {"\_index":"db54","\_type":"metadata","\_id":"0010000025","\_sc  
> ore":1.0},  
> {"\_index":"db54","\_type":"metadata","\_id":"0010000032","\_score":1.0},{  
> "\_index":"db54","\_type":"metadata","\_id":"0010000037","\_score":1.0},  
> {"\_index":"d  
> b54","\_type":"metadata","\_id":"0010000044","\_score":1.0},  
> {"\_index":"db54","\_type  
> ":"metadata","\_id":"0010000049","\_score":1.0},  
> {"\_index":"db54","\_type":"metadata  
> ","\_id":"0010000051","\_score":1.0},  
> {"\_index":"db54","\_type":"metadata","\_id":"00  
> 10000056","\_score":1.0}]}}

Can any one help me to move forward...

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 19, 2011, 9:03am UTC](https://discuss.elastic.co/t/has-child-query-exception/4247/2 "2011-04-19T09:03:04Z")

</div>

Can you gist a recreation? See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)  
On Monday, April 18, 2011 at 12:48 PM, senthil prabhu wrote:

> Hi All,  
> To retrieve documents in parent table i am using the "has-  
> child query". I have 9 documents in child table but while querying i  
> am getting only 5 documents with Exception.
> 
> I am using the elasticsearch version 15.2
> 
> curl -XGET '[http://localhost:9200/db54/metadata/\_search](http://localhost:9200/db54/metadata/_search)' -d '{ "query":  
> {"has\_child" : {"type" : "childtable", "query" :{ "term" : { "field1":  
> "12" } }} } }'
> 
> {"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":  
> 3,"failed":2,"fail  
> ures":[{"index":"db54","shard":  
> 3,"reason":"QueryPhaseExecutionException[[db54][3  
> ]: query[ConstantScore(child\_filter[childtable/metadata]  
> (filtered(field1:12)-
> 
> > FilterCacheFilterWrapper(\_type:childtable)))],from[0],size[10]: Query  
> > Fa  
> > iled [Failed to execute child query [filtered(\_included:status2status)-  
> > FilterCa  
> > cheFilterWrapper(\_type:childtable)]]]; nested: "},  
> > {"index":"db54","shard":4,"reaso  
> > n":"QueryPhaseExecutionException[[db54][4]:  
> > query[ConstantScore(child\_filter[childtable/metadata](filtered(field1:  
> > 12)-\>FilterCacheFilterWrapper(\_typ  
> > e:childtable)))],from[0],size[10]: Query Failed [Failed to execute  
> > child query [fi  
> > ltered(field1:12)-\>FilterCacheFilterWrapper(\_type:childtable)]]]; ne  
> > sted: "}]},"hits":{"total":53,"max\_score":1.0,"hits":  
> > [{"\_index":"db54","\_type":"  
> > metadata","\_id":"0010000013","\_score":1.0},  
> > {"\_index":"db54","\_type":"metadata","  
> > \_id":"0010000018","\_score":1.0},  
> > {"\_index":"db54","\_type":"metadata","\_id":"00100  
> > 00020","\_score":1.0},  
> > {"\_index":"db54","\_type":"metadata","\_id":"0010000025","\_sc  
> > ore":1.0},  
> > {"\_index":"db54","\_type":"metadata","\_id":"0010000032","\_score":1.0},{  
> > "\_index":"db54","\_type":"metadata","\_id":"0010000037","\_score":1.0},  
> > {"\_index":"d  
> > b54","\_type":"metadata","\_id":"0010000044","\_score":1.0},  
> > {"\_index":"db54","\_type  
> > ":"metadata","\_id":"0010000049","\_score":1.0},  
> > {"\_index":"db54","\_type":"metadata  
> > ","\_id":"0010000051","\_score":1.0},  
> > {"\_index":"db54","\_type":"metadata","\_id":"00  
> > 10000056","\_score":1.0}]}}
> 
> Can any one help me to move forward...

---

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [April 19, 2011, 12:24pm UTC](https://discuss.elastic.co/t/has-child-query-exception/4247/3 "2011-04-19T12:24:11Z")

</div>

Here i have mentioned Parent table mapping

$ curl -XGET '[http://localhost:9200/db54/metadata/\_mapping](http://localhost:9200/db54/metadata/_mapping)'  
{"db54":{"metadata":{"\_source":{"enabled":false},"properties":  
{"field1":  
{"store":"yes","analyzer":"keyword","type":"string"},"field2":  
{"store":"yes","analyzer":"keyword","term\_vector":"with\_positions\_offse  
ts","type":"string"},"field3":  
{"store":"yes","analyzer":"standard","type":  
"string"},"field4":  
{"store":"yes","analyzer":"standard","term\_vector":"with  
\_positions\_offsets","type":"string"}}}}}

Here i have mentioned Child table mapping

$ curl -XGET '[http://localhost:9200/db54/included/\_mapping](http://localhost:9200/db54/included/_mapping)'  
{"db54":{"included":{"\_routing":{"required":true},"properties":  
{"\_included":{"st  
ore":"yes","analyzer":"standard","type":"string"},"parentrelationid":  
{"omit\_term  
\_freq\_and\_positions":false,"index":"analyzed","omit\_norms":false,"store":"yes","  
type":"long"},"\_updatedby":  
{"omit\_term\_freq\_and\_positions":false,"omit\_norms":fa  
lse,"store":"yes","type":"long"},"\_updatedon":  
{"omit\_term\_freq\_and\_positions":fa  
lse,"omit\_norms":false,"store":"yes","format":"MMM/dd/yyyy  
HH:mm:ss","type":"dat  
e"}},"\_parent":{"type":"metadata"}}}}

I am searching using the below query

$ curl -XGET '[http://localhost:9200/db54/metadata/\_search](http://localhost:9200/db54/metadata/_search)'?pretty=true  
-d '  
{ "query":{"has\_child" : {"type" : "included", "query" :{ "term" :  
{ "\_included  
":"status2status" } }} } }'  
{  
"took" : 0,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 3,  
"failed" : 2,  
"failures" : [ {  
"index" : "db54",  
"shard" : 3,  
"reason" : "QueryPhaseExecutionException[[db54][3]:  
query[ConstantScore(ch  
ild\_filter[included/metadata](filtered(\_included:status2status)-

> FilterCacheFilt  
> erWrapper(\_type:included)))],from[0],size[10]: Query Failed [Failed to  
> execute c  
> hild query [filtered(\_included:status2status)-  
> FilterCacheFilterWrapper(\_type:in  
> cluded)]]]; nested: "  
> }, {  
> "index" : "db54",  
> "shard" : 4,  
> "reason" : "QueryPhaseExecutionException[[db54][4]:  
> query[ConstantScore(ch  
> ild\_filter[included/metadata](filtered(\_included:status2status)-  
> FilterCacheFilt  
> erWrapper(\_type:included)))],from[0],size[10]: Query Failed [Failed to  
> execute c  
> hild query [filtered(\_included:status2status)-  
> FilterCacheFilterWrapper(\_type:in  
> cluded)]]]; nested: "  
> } ]  
> },  
> "hits" : {  
> "total" : 53,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000037",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000044",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000049",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000051",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000056",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000063",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000068",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000070",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000075",  
> "\_score" : 1.0  
> }, {  
> "\_index" : "db54",  
> "\_type" : "metadata",  
> "\_id" : "0010000082",  
> "\_score" : 1.0  
> } ]  
> }  
> }

I have 90 documents in parent and child table, but i am getting only  
53 documents here.

On Apr 19, 2:03 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Can you gist a recreation? Seehttp://www.elasticsearch.org/help
> 
> On Monday, April 18, 2011 at 12:48 PM, senthil prabhu wrote:
> 
> > Hi All,  
> > To retrieve documents in parent table i am using the "has-  
> > child query". I have 9 documents in child table but while querying i  
> > am getting only 5 documents with Exception.
> 
> > I am using the elasticsearch version 15.2
> 
> > curl -XGET '[http://localhost:9200/db54/metadata/\_search'-d](http://localhost:9200/db54/metadata/_search'-d) '{ "query":  
> > {"has\_child" : {"type" : "childtable", "query" :{ "term" : { "field1":  
> > "12" } }} } }'
> 
> > {"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":  
> > 3,"failed":2,"fail  
> > ures":[{"index":"db54","shard":  
> > 3,"reason":"QueryPhaseExecutionException[[db54][3  
> > ]: query[ConstantScore(child\_filter[childtable/metadata]  
> > (filtered(field1:12)-
> > 
> > > FilterCacheFilterWrapper(\_type:childtable)))],from[0],size[10]: Query  
> > > Fa  
> > > iled [Failed to execute child query [filtered(\_included:status2status)-  
> > > FilterCa  
> > > cheFilterWrapper(\_type:childtable)]]]; nested: "},  
> > > {"index":"db54","shard":4,"reaso  
> > > n":"QueryPhaseExecutionException[[db54][4]:  
> > > query[ConstantScore(child\_filter[childtable/metadata](filtered(field1:  
> > > 12)-\>FilterCacheFilterWrapper(\_typ  
> > > e:childtable)))],from[0],size[10]: Query Failed [Failed to execute  
> > > child query [fi  
> > > ltered(field1:12)-\>FilterCacheFilterWrapper(\_type:childtable)]]]; ne  
> > > sted: "}]},"hits":{"total":53,"max\_score":1.0,"hits":  
> > > [{"\_index":"db54","\_type":"  
> > > metadata","\_id":"0010000013","\_score":1.0},  
> > > {"\_index":"db54","\_type":"metadata","  
> > > \_id":"0010000018","\_score":1.0},  
> > > {"\_index":"db54","\_type":"metadata","\_id":"00100  
> > > 00020","\_score":1.0},  
> > > {"\_index":"db54","\_type":"metadata","\_id":"0010000025","\_sc  
> > > ore":1.0},  
> > > {"\_index":"db54","\_type":"metadata","\_id":"0010000032","\_score":1.0},{  
> > > "\_index":"db54","\_type":"metadata","\_id":"0010000037","\_score":1.0},  
> > > {"\_index":"d  
> > > b54","\_type":"metadata","\_id":"0010000044","\_score":1.0},  
> > > {"\_index":"db54","\_type  
> > > ":"metadata","\_id":"0010000049","\_score":1.0},  
> > > {"\_index":"db54","\_type":"metadata  
> > > ","\_id":"0010000051","\_score":1.0},  
> > > {"\_index":"db54","\_type":"metadata","\_id":"00  
> > > 10000056","\_score":1.0}]}}
> 
> > Can any one help me to move forward...

---

<div class="post-metadata">

**Author:** ![Lar\_Mader](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lar\_Mader](https://discuss.elastic.co/u/Lar_Mader)\
**Post date:** [April 19, 2011, 4:53pm UTC](https://discuss.elastic.co/t/has-child-query-exception/4247/4 "2011-04-19T16:53:20Z")

</div>

In some ways this looks similar to the problem I am having with parent/  
child documents. My scenario seems to occur after indexing some docs,  
deleting some docs, and indexing more docs. After awhile I get shard  
failures, and a NullPointer exception in the elastic log. The shard  
failures look like this:

[shard [[8ZUq44E3QUu8XPbPvb9yfA][acme][2]], reason  
[RemoteTransportException[[Ardina][inet[/10.10.30.52:9300]][search/  
phase/query]]; nested: QueryPhaseExecutionException[[acme][2]:  
query[title:someTitle ConstantScore(child\_filter[contentFiles/content]  
(filtered(file:test)-

> FilterCacheFilterWrapper(\_type:contentFiles)))],from[0],size[10]:  
> Query Failed [Failed to execute child query [filtered(file:test)-  
> FilterCacheFilterWrapper(\_type:contentFiles)]]]; nested: ]]

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:08am UTC](https://discuss.elastic.co/t/has-child-query-exception/4247/5 "2017-07-06T04:08:04Z")

</div>


