# hasParentFilter not working in SearchScrollRequestBuilder in v0.90.10

**URL:** https://discuss.elastic.co/t/hasparentfilter-not-working-in-searchscrollrequestbuilder-in-v0-90-10/15211
**Category:** Elasticsearch
**Created:** [January 12, 2014, 4:51am UTC](https://discuss.elastic.co/t/hasparentfilter-not-working-in-searchscrollrequestbuilder-in-v0-90-10/15211 "2014-01-12T04:51:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sandeep\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep_jain/32/1869_2.png) [@Sandeep\_Jain](https://discuss.elastic.co/u/Sandeep_Jain)
#### Post date: [January 12, 2014, 4:51am UTC](https://discuss.elastic.co/t/hasparentfilter-not-working-in-searchscrollrequestbuilder-in-v0-90-10/15211/1 "2014-01-12T04:51:00Z")

</div>

Hi,

After version upgrading to 0.90.10, I am facing a issue in  
SearchScrollRequestBuilder when query having parent filters, the response  
having the following failure message:

{  
"took" : 45,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 0,  
"failed" : 1,  
"failures" : [ {  
"index" : "12345",  
"shard" : 1,  
"status" : 500,  
"reason" :  
"RemoteTransportException[[Americop][inet[/10.0.0.5:9300]][search/phase/scan/scroll]];  
nested: QueryPhaseExecutionException[[12345][1]:  
query[ConstantScore(cache(\_type:CTable))],from[0],size[10000]: Query Failed  
[Failed to execute main query]]; nested: NullPointerException; "  
} ]  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 0.0,  
"hits" : []  
}  
}

the same request working successfully via SearchRequestBuilder or REST.

Am I missing something as it was running fine in version 0.90.5 ?

To reproduce the same :

curl -XPOST '[http://localhost:9200/12345](http://localhost:9200/12345)'

curl -XPUT '[http://localhost:9200/12345/PTable/row1?routing=12345](http://localhost:9200/12345/PTable/row1?routing=12345)' -d '{  
"user" : "dev-elasticsearch",  
"post\_date" : "2014-01-12",  
"message" : "search with hasParentFilter in scroll not working"  
}'

Run the following code :  
public static void main(String[] args) {  
Client client = NodeBuilder.nodeBuilder().node().client();  
/\*  
PutMappingRequestBuilder pmrb = client.admin().indices()  
.preparePutMapping("12345").setType("CTable");

pmrb.setSource("{"CTable":{"\_parent":{"type":"PTable"},"\_routing":{"required":true}}}");  
pmrb.execute().actionGet();  
IndexRequestBuilder irb = new IndexRequestBuilder(client);  
irb.setIndex("12345");  
irb.setType("CTable");  
irb.setId("childRow1");  
irb.setRouting("12345");  
irb.setParent("row1");  
Map\<String, Object\> data = new HashMap\<String, Object\>();  
data.put("col1", "val1");  
irb.setSource(data);  
irb.execute().actionGet();\*/

```
    SearchRequestBuilder searchRequestBuilder = new 

```

SearchRequestBuilder(  
client);  
searchRequestBuilder.setIndices("12345");  
searchRequestBuilder.setTypes("CTable");  
searchRequestBuilder.setRouting("12345");  
FilterBuilder postFilter = FilterBuilders.hasParentFilter("PTable",  
FilterBuilders.termFilter("user", "elasticsearch"));  
searchRequestBuilder.setPostFilter(postFilter);  
searchRequestBuilder.addField("col1");  
searchRequestBuilder.setScroll("5m");  
searchRequestBuilder.setSearchType(SearchType.SCAN);  
searchRequestBuilder.setSize(10000);  
SearchResponse sr = searchRequestBuilder.execute().actionGet();

```
    String scrollId = sr.getScrollId();
    SearchScrollRequestBuilder searchScrollRequestBuilder = new 

```

SearchScrollRequestBuilder(  
client);  
searchScrollRequestBuilder.setScrollId(scrollId);  
SearchResponse searchScrollResponse = searchScrollRequestBuilder  
.execute().actionGet();  
ClearScrollRequestBuilder clearScrollRequestBuilder = new  
ClearScrollRequestBuilder(  
client);  
clearScrollRequestBuilder.addScrollId(scrollId);  
boolean isCleared = clearScrollRequestBuilder.execute().actionGet()  
.isSucceeded();  
System.out.println(searchScrollResponse.getShardFailures());  
}

Thanks

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1652d726-6e9e-4e91-a222-a06128182a8a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1652d726-6e9e-4e91-a222-a06128182a8a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [January 14, 2014, 11:53am UTC](https://discuss.elastic.co/t/hasparentfilter-not-working-in-searchscrollrequestbuilder-in-v0-90-10/15211/2 "2014-01-14T11:53:17Z")

</div>

Hey,

when you run NodeBuilder.nodeBuilder().node().client() - you are actually  
starting another elasticsearch instance. Is that intended?  
Why are returining JSON data, when executing java classes (I am a bit  
confused).

Can you create a gist, which only contains curl calls or only contains a  
Java API in order to rule out you run two different instances? Thanks!

--Alex

On Sun, Jan 12, 2014 at 5:51 AM, Sandeep Jain [sandy6jain@gmail.com](mailto:sandy6jain@gmail.com) wrote:

> Hi,
> 
> After version upgrading to 0.90.10, I am facing a issue in  
> SearchScrollRequestBuilder when query having parent filters, the response  
> having the following failure message:
> 
> {  
> "took" : 45,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 0,  
> "failed" : 1,  
> "failures" : [ {  
> "index" : "12345",  
> "shard" : 1,  
> "status" : 500,  
> "reason" : "RemoteTransportException[[Americop][inet[/10.0.0.5:9300]][search/phase/scan/scroll]];  
> nested: QueryPhaseExecutionException[[12345][1]:  
> query[ConstantScore(cache(\_type:CTable))],from[0],size[10000]: Query Failed  
> [Failed to execute main query]]; nested: NullPointerException; "  
> } ]  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 0.0,  
> "hits" :   
> }  
> }
> 
> the same request working successfully via SearchRequestBuilder or REST.
> 
> Am I missing something as it was running fine in version 0.90.5 ?
> 
> To reproduce the same :
> 
> curl -XPOST '[http://localhost:9200/12345](http://localhost:9200/12345)'
> 
> curl -XPUT '[http://localhost:9200/12345/PTable/row1?routing=12345](http://localhost:9200/12345/PTable/row1?routing=12345)' -d '{  
> "user" : "dev-elasticsearch",  
> "post\_date" : "2014-01-12",  
> "message" : "search with hasParentFilter in scroll not working"  
> }'
> 
> Run the following code :  
> public static void main(String args) {  
> Client client = NodeBuilder.nodeBuilder().node().client();  
> /\*  
> PutMappingRequestBuilder pmrb = client.admin().indices()  
> .preparePutMapping("12345").setType("CTable");
> 
> pmrb.setSource("{"CTable":{"\_parent":{"type":"PTable"},"\_routing":{"required":true}}}");  
> pmrb.execute().actionGet();  
> IndexRequestBuilder irb = new IndexRequestBuilder(client);  
> irb.setIndex("12345");  
> irb.setType("CTable");  
> irb.setId("childRow1");  
> irb.setRouting("12345");  
> irb.setParent("row1");  
> Map\<String, Object\> data = new HashMap\<String, Object\>();  
> data.put("col1", "val1");  
> irb.setSource(data);  
> irb.execute().actionGet();\*/
> 
> ```
> SearchRequestBuilder searchRequestBuilder = new
> 
> ```
> 
> SearchRequestBuilder(  
> client);  
> searchRequestBuilder.setIndices("12345");  
> searchRequestBuilder.setTypes("CTable");  
> searchRequestBuilder.setRouting("12345");  
> FilterBuilder postFilter = FilterBuilders.hasParentFilter("PTable",  
> FilterBuilders.termFilter("user", "elasticsearch"));  
> searchRequestBuilder.setPostFilter(postFilter);  
> searchRequestBuilder.addField("col1");  
> searchRequestBuilder.setScroll("5m");  
> searchRequestBuilder.setSearchType(SearchType.SCAN);  
> searchRequestBuilder.setSize(10000);  
> SearchResponse sr = searchRequestBuilder.execute().actionGet();
> 
> ```
> String scrollId = sr.getScrollId();
> SearchScrollRequestBuilder searchScrollRequestBuilder = new
> 
> ```
> 
> SearchScrollRequestBuilder(  
> client);  
> searchScrollRequestBuilder.setScrollId(scrollId);  
> SearchResponse searchScrollResponse = searchScrollRequestBuilder  
> .execute().actionGet();  
> ClearScrollRequestBuilder clearScrollRequestBuilder = new  
> ClearScrollRequestBuilder(  
> client);  
> clearScrollRequestBuilder.addScrollId(scrollId);  
> boolean isCleared = clearScrollRequestBuilder.execute().actionGet()  
> .isSucceeded();  
> System.out.println(searchScrollResponse.getShardFailures());  
> }
> 
> Thanks
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1652d726-6e9e-4e91-a222-a06128182a8a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1652d726-6e9e-4e91-a222-a06128182a8a%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM\_A7N%3DjvUQANxOnPOZ%3Dy%3D5u%2BoQUMBhfU1NoUMvFETd9Qg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_A7N%3DjvUQANxOnPOZ%3Dy%3D5u%2BoQUMBhfU1NoUMvFETd9Qg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Sandeep\_Jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep_jain/32/1869_2.png) [@Sandeep\_Jain](https://discuss.elastic.co/u/Sandeep_Jain)
#### Post date: [January 14, 2014, 4:37pm UTC](https://discuss.elastic.co/t/hasparentfilter-not-working-in-searchscrollrequestbuilder-in-v0-90-10/15211/3 "2014-01-14T16:37:39Z")

</div>

Hi Alex,

I configured client as true in classpath & having a static node instance in  
my app, so not creating instance on each query.  
I had created gist for the same: [no hits with hasParentFilter in request via SearchScrollRequestBuilder in v0.90.10 · GitHub](https://gist.github.com/sandy6jain/8421029)

Thanks

On Tuesday, January 14, 2014 3:53:17 AM UTC-8, Alexander Reelsen wrote:

> Hey,
> 
> when you run NodeBuilder.nodeBuilder().node().client() - you are actually  
> starting another elasticsearch instance. Is that intended?  
> Why are returining JSON data, when executing java classes (I am a bit  
> confused).
> 
> Can you create a gist, which only contains curl calls or only contains a  
> Java API in order to rule out you run two different instances? Thanks!
> 
> --Alex
> 
> On Sun, Jan 12, 2014 at 5:51 AM, Sandeep Jain \<[sandy...@gmail.com](mailto:sandy...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi,
> > 
> > After version upgrading to 0.90.10, I am facing a issue in  
> > SearchScrollRequestBuilder when query having parent filters, the response  
> > having the following failure message:
> > 
> > {  
> > "took" : 45,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 1,  
> > "successful" : 0,  
> > "failed" : 1,  
> > "failures" : [ {  
> > "index" : "12345",  
> > "shard" : 1,  
> > "status" : 500,  
> > "reason" :  
> > "RemoteTransportException[[Americop][inet[/10.0.0.5:9300]][search/phase/scan/scroll]];  
> > nested: QueryPhaseExecutionException[[12345][1]:  
> > query[ConstantScore(cache(\_type:CTable))],from[0],size[10000]: Query Failed  
> > [Failed to execute main query]]; nested: NullPointerException; "  
> > } ]  
> > },  
> > "hits" : {  
> > "total" : 1,  
> > "max\_score" : 0.0,  
> > "hits" :   
> > }  
> > }
> > 
> > the same request working successfully via SearchRequestBuilder or REST.
> > 
> > Am I missing something as it was running fine in version 0.90.5 ?
> > 
> > To reproduce the same :
> > 
> > curl -XPOST '[http://localhost:9200/12345](http://localhost:9200/12345)'
> > 
> > curl -XPUT '[http://localhost:9200/12345/PTable/row1?routing=12345](http://localhost:9200/12345/PTable/row1?routing=12345)' -d '{  
> > "user" : "dev-elasticsearch",  
> > "post\_date" : "2014-01-12",  
> > "message" : "search with hasParentFilter in scroll not working"  
> > }'
> > 
> > Run the following code :  
> > public static void main(String args) {  
> > Client client = NodeBuilder.nodeBuilder().node().client();  
> > /\*  
> > PutMappingRequestBuilder pmrb = client.admin().indices()  
> > .preparePutMapping("12345").setType("CTable");
> > 
> > pmrb.setSource("{"CTable":{"\_parent":{"type":"PTable"},"\_routing":{"required":true}}}");  
> > pmrb.execute().actionGet();  
> > IndexRequestBuilder irb = new IndexRequestBuilder(client);  
> > irb.setIndex("12345");  
> > irb.setType("CTable");  
> > irb.setId("childRow1");  
> > irb.setRouting("12345");  
> > irb.setParent("row1");  
> > Map\<String, Object\> data = new HashMap\<String, Object\>();  
> > data.put("col1", "val1");  
> > irb.setSource(data);  
> > irb.execute().actionGet();\*/
> > 
> > ```
> > SearchRequestBuilder searchRequestBuilder = new 
> > 
> > ```
> > 
> > SearchRequestBuilder(  
> > client);  
> > searchRequestBuilder.setIndices("12345");  
> > searchRequestBuilder.setTypes("CTable");  
> > searchRequestBuilder.setRouting("12345");  
> > FilterBuilder postFilter =  
> > FilterBuilders.hasParentFilter("PTable",  
> > FilterBuilders.termFilter("user", "elasticsearch"));  
> > searchRequestBuilder.setPostFilter(postFilter);  
> > searchRequestBuilder.addField("col1");  
> > searchRequestBuilder.setScroll("5m");  
> > searchRequestBuilder.setSearchType(SearchType.SCAN);  
> > searchRequestBuilder.setSize(10000);  
> > SearchResponse sr = searchRequestBuilder.execute().actionGet();
> > 
> > ```
> > String scrollId = sr.getScrollId();
> > SearchScrollRequestBuilder searchScrollRequestBuilder = new 
> > 
> > ```
> > 
> > SearchScrollRequestBuilder(  
> > client);  
> > searchScrollRequestBuilder.setScrollId(scrollId);  
> > SearchResponse searchScrollResponse = searchScrollRequestBuilder  
> > .execute().actionGet();  
> > ClearScrollRequestBuilder clearScrollRequestBuilder = new  
> > ClearScrollRequestBuilder(  
> > client);  
> > clearScrollRequestBuilder.addScrollId(scrollId);  
> > boolean isCleared =  
> > clearScrollRequestBuilder.execute().actionGet()  
> > .isSucceeded();  
> > System.out.println(searchScrollResponse.getShardFailures());  
> > }
> > 
> > Thanks
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/1652d726-6e9e-4e91-a222-a06128182a8a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1652d726-6e9e-4e91-a222-a06128182a8a%40googlegroups.com)  
> > .  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bd95101e-9107-4958-a832-2c9f25af3c4d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bd95101e-9107-4958-a832-2c9f25af3c4d%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Dan\_Everton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_everton/32/1865_2.png) [@Dan\_Everton](https://discuss.elastic.co/u/Dan_Everton)
#### Post date: [January 14, 2014, 10:04pm UTC](https://discuss.elastic.co/t/hasparentfilter-not-working-in-searchscrollrequestbuilder-in-v0-90-10/15211/4 "2014-01-14T22:04:07Z")

</div>

This looks similar to this  
bug [https://github.com/elasticsearch/elasticsearch/issues/4703](https://github.com/elasticsearch/elasticsearch/issues/4703) thought  
that's with has\_child filters and doesn't throw an error. I wonder if it's  
a related issue though?

There's both curl and JUnit test cases attached there if that helps.

Cheers,  
Dan

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fd4e6e2b-5341-4865-953a-d76666ffba0a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fd4e6e2b-5341-4865-953a-d76666ffba0a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:56am UTC](https://discuss.elastic.co/t/hasparentfilter-not-working-in-searchscrollrequestbuilder-in-v0-90-10/15211/5 "2017-07-06T01:56:46Z")

</div>


