# No hit using scan/scroll with has\_parent filter

**URL:** https://discuss.elastic.co/t/no-hit-using-scan-scroll-with-has-parent-filter/15143
**Category:** Elasticsearch
**Created:** [January 8, 2014, 2:17pm UTC](https://discuss.elastic.co/t/no-hit-using-scan-scroll-with-has-parent-filter/15143 "2014-01-08T14:17:03Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Jean\_Baptiste\_Lievre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jean_baptiste_lievre/32/1870_2.png) [@Jean\_Baptiste\_Lievre](https://discuss.elastic.co/u/Jean_Baptiste_Lievre)
#### Post date: [January 10, 2014, 4:53pm UTC](https://discuss.elastic.co/t/no-hit-using-scan-scroll-with-has-parent-filter/15143/4 "2014-01-10T16:53:24Z")

</div>

Going further on the subject, I have tried to work around the issue using a  
filtered query, to no avail.

So basically, if I want to fetch all child document IDs that match a given  
criterion on their parent, I have either to

- use a query - which in my case requires that I duplicate the existing  
code that builds a filter, building a query instead
- or do it in 2 requests, one to count the totalHits matching the criteria,  
the second using totalHits in the "size" parameter to fetch all IDs at once

Is there any other solution?

Le jeudi 9 janvier 2014 10:18:25 UTC+1, Jean-Baptiste Lièvremont a écrit :

> Hi Martijn,
> 
> Thanks for your answer. You can find in the gist below some HTTP  
> conversations made on my ES 0.90.6 node, as well as a link to the Java code  
> responsible for the calls:  
> [The attached files describe HTTP exchanges made with the REST API of an ElasticSearch 0.90.6 node, to describe the problem encountered in this thread: https://groups.google.com/forum/#!topic/elasticsearch/pfQ1wiTeObk The node has one index named 'rules' with 2 types ('rule' and 'active\_rule'). The Java code responsible for the calls can be found at: https://github.com/SonarSource/sonar/blob/master/sonar-server/src/main/java/org/sonar/server/rule/ProfileRules.java?source=cc#L116 · GitHub](https://gist.github.com/jblievremont/8331460)
> 
> Please note that the issue appears only when combining scan/scroll with  
> has\_parent filter, as it seems to work using a has\_parent query instead.
> 
> Best regards,  
> -- Jean-Baptiste Lièvremont
> 
> Le jeudi 9 janvier 2014 00:18:14 UTC+1, Martijn v Groningen a écrit :
> 
> > Hi Jean,
> > 
> > Can you share how you execute the scan request with the has\_parent  
> > filter? (via a gist or something like that)
> > 
> > Martijn
> > 
> > On 8 January 2014 15:17, Jean-Baptiste Lièvremont \<  
> > [jean-baptist...@sonarsource.com](mailto:jean-baptist...@sonarsource.com)\> wrote:
> > 
> > > Hi folks,
> > > 
> > > I use a parent/child mapping configuration which works flawlessly with  
> > > "classic" search requests, e.g using has\_parent to find child documents  
> > > with criteria on the parent documents.
> > > 
> > > I am trying to get all child document IDs that match a given set of  
> > > criteria using scan and scroll, which also works well - until I introduce  
> > > the has\_parent filter, in which case the scroll request returns no hit  
> > > (although total\_hits is correct).
> > > 
> > > Is it a known issue?
> > > 
> > > I can provide sample mapping files and queries with associated/expected  
> > > results. Please note that this behavior has been noticed on 0.90.6 but is  
> > > still present in 0.90.9.
> > > 
> > > Thanks, best regards,  
> > > -- Jean-Baptiste Lièvremont
> > > 
> > > --  
> > > 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).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/fd7c563e-34f7-4aa8-ab1a-460840ba2af0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fd7c563e-34f7-4aa8-ab1a-460840ba2af0%40googlegroups.com)  
> > > .  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > Met vriendelijke groet,
> > 
> > Martijn van Groningen

--  
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/374c3350-ca10-4699-9aae-b72087aba07a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/374c3350-ca10-4699-9aae-b72087aba07a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

_[View the full topic](https://discuss.elastic.co/t/no-hit-using-scan-scroll-with-has-parent-filter/15143)._
