# How to debug queries in elastic search

**URL:** https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125
**Category:** Elasticsearch
**Created:** [May 26, 2013, 8:00am UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125 "2013-05-26T08:00:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Deep\_2](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Deep\_2](https://discuss.elastic.co/u/Deep_2)
#### Post date: [May 26, 2013, 8:00am UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/1 "2013-05-26T08:00:44Z")

</div>

Hi ,

I need help to debug my query in elastic search. I have a parent / child  
relationship. My query is not returning any results. How can I debug issue  
the issue?

Regards,

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 26, 2013, 8:53am UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/2 "2013-05-26T08:53:33Z")

</div>

You can use explain API: [http://www.elasticsearch.org/guide/reference/api/explain/](http://www.elasticsearch.org/guide/reference/api/explain/)

Or ask here for advices. See [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 26 mai 2013 à 10:00, Deep [ishwardeep@gmail.com](mailto:ishwardeep@gmail.com) a écrit :

Hi ,

I need help to debug my query in elastic search. I have a parent / child relationship. My query is not returning any results. How can I debug issue the issue?

## Regards,

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).  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Deep\_2](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Deep\_2](https://discuss.elastic.co/u/Deep_2)
#### Post date: [May 26, 2013, 11:51am UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/3 "2013-05-26T11:51:06Z")

</div>

Hi David,  
Thank you for your response.

I read thru the explain api documentation but it does not seem to help if  
the query does not return any results.

If you could help me with the query it would be highly appreciated.

I have attached my schema , dummy data and query file. I want to return all  
ads for which the in the parent all the targeting parameters in the parent  
adgroup are met (adgroup must be active, keyword must exist in kwtargetting  
and the publisher budget must be \> 0 for a publisher).

Thanks

On Sunday, 26 May 2013 14:23:33 UTC+5:30, David Pilato wrote:

> You can use explain API:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/explain/)
> 
> Or ask here for advices. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 26 mai 2013 à 10:00, Deep \<[ishwa...@gmail.com](mailto:ishwa...@gmail.com) \<javascript:\>\> a écrit :
> 
> Hi ,
> 
> I need help to debug my query in Elasticsearch. I have a parent / child  
> relationship. My query is not returning any results. How can I debug issue  
> the issue?
> 
> Regards,
> 
> --  
> 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:\>.  
> 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 26, 2013, 12:13pm UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/4 "2013-05-26T12:13:56Z")

</div>

Did you read the help page?  
Please gist a full curl recreation (something we can easily replay from scratch) and we will be happy to help.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 26 mai 2013 à 13:51, Deep [ishwardeep@gmail.com](mailto:ishwardeep@gmail.com) a écrit :

Hi David,  
Thank you for your response.

I read thru the explain api documentation but it does not seem to help if the query does not return any results.

If you could help me with the query it would be highly appreciated.

I have attached my schema , dummy data and query file. I want to return all ads for which the in the parent all the targeting parameters in the parent adgroup are met (adgroup must be active, keyword must exist in kwtargetting and the publisher budget must be \> 0 for a publisher).

Thanks

On Sunday, 26 May 2013 14:23:33 UTC+5:30, David Pilato wrote:

> You can use explain API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/explain/)
> 
> Or ask here for advices. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 26 mai 2013 à 10:00, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> 
> Hi ,
> 
> I need help to debug my query in Elasticsearch. I have a parent / child relationship. My query is not returning any results. How can I debug issue the issue?
> 
> ## Regards,
> 
> 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).  
> 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

\<campaign\_adgrp\_schema.json\>  
\<distance-filter-query-parent-6.json\>

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Deep\_2](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Deep\_2](https://discuss.elastic.co/u/Deep_2)
#### Post date: [May 26, 2013, 7:11pm UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/5 "2013-05-26T19:11:16Z")

</div>

Hi David,

Although I am not sure but it seems that the issue is due to routing value.  
Just keeping 1 shard and got my query partially running.

The complete list of commands to reproduce the issue are:

//create schema definition  
curl -XPOST [http://localhost:9200/ads](http://localhost:9200/ads) -d@campaign\_adgrp\_schema.json

//load data  
curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary  
@./fedexadgroupcampaign.txt  
curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary @./0\_comcat.txt

//search in these queries the explain shows that match for kwtargeting is  
not working. the query needs to be fixed  
curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)"  
-d@./distance-filter-query-parent-6.json  
curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)"  
-d@./distance-filter-query-parent-7.json

Looking forward to hear from you soon.  
Regards,  
Deep

On Sunday, 26 May 2013 17:43:56 UTC+5:30, David Pilato wrote:

> Did you read the help page?  
> Please gist a full curl recreation (something we can easily replay from  
> scratch) and we will be happy to help.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 26 mai 2013 à 13:51, Deep \<[ishwa...@gmail.com](mailto:ishwa...@gmail.com) \<javascript:\>\> a écrit :
> 
> Hi David,  
> Thank you for your response.
> 
> I read thru the explain api documentation but it does not seem to help if  
> the query does not return any results.
> 
> If you could help me with the query it would be highly appreciated.
> 
> I have attached my schema , dummy data and query file. I want to return  
> all ads for which the in the parent all the targeting parameters in the  
> parent adgroup are met (adgroup must be active, keyword must exist in  
> kwtargetting and the publisher budget must be \> 0 for a publisher).
> 
> Thanks
> 
> On Sunday, 26 May 2013 14:23:33 UTC+5:30, David Pilato wrote:
> 
> > You can use explain API:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/explain/)
> > 
> > Or ask here for advices. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 26 mai 2013 à 10:00, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > 
> > Hi ,
> > 
> > I need help to debug my query in Elasticsearch. I have a parent / child  
> > relationship. My query is not returning any results. How can I debug issue  
> > the issue?
> > 
> > Regards,
> > 
> > --  
> > 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).  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> \<campaign\_adgrp\_schema.json\>  
> \<distance-filter-query-parent-6.json\>

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 27, 2013, 1:28pm UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/6 "2013-05-27T13:28:00Z")

</div>

Hi Deep,

If you want to fix routing value, then you have to send all children to the same shard than parent. So use the same \_routing parameter for all documents.  
If you set for parent a custom routing value, then you have to set the same one for all children.

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 26 mai 2013 à 21:11, Deep [ishwardeep@gmail.com](mailto:ishwardeep@gmail.com) a écrit :

> Hi David,
> 
> Although I am not sure but it seems that the issue is due to routing value. Just keeping 1 shard and got my query partially running.
> 
> The complete list of commands to reproduce the issue are:
> 
> //create schema definition  
> curl -XPOST [http://localhost:9200/ads](http://localhost:9200/ads) -d@campaign\_adgrp\_schema.json
> 
> //load data  
> curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary @./fedexadgroupcampaign.txt  
> curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary @./0\_comcat.txt
> 
> //search in these queries the explain shows that match for kwtargeting is not working. the query needs to be fixed  
> curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)" -d@./distance-filter-query-parent-6.json  
> curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)" -d@./distance-filter-query-parent-7.json
> 
> Looking forward to hear from you soon.  
> Regards,  
> Deep
> 
> On Sunday, 26 May 2013 17:43:56 UTC+5:30, David Pilato wrote:  
> Did you read the help page?  
> Please gist a full curl recreation (something we can easily replay from scratch) and we will be happy to help.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 26 mai 2013 à 13:51, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> 
> Hi David,  
> Thank you for your response.
> 
> I read thru the explain api documentation but it does not seem to help if the query does not return any results.
> 
> If you could help me with the query it would be highly appreciated.
> 
> I have attached my schema , dummy data and query file. I want to return all ads for which the in the parent all the targeting parameters in the parent adgroup are met (adgroup must be active, keyword must exist in kwtargetting and the publisher budget must be \> 0 for a publisher).
> 
> Thanks
> 
> On Sunday, 26 May 2013 14:23:33 UTC+5:30, David Pilato wrote:  
> You can use explain API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/explain/)
> 
> Or ask here for advices. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 26 mai 2013 à 10:00, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> 
> Hi ,
> 
> I need help to debug my query in Elasticsearch. I have a parent / child relationship. My query is not returning any results. How can I debug issue the issue?
> 
> Regards,
> 
> --  
> 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).  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> \<campaign\_adgrp\_schema.json\>  
> \<distance-filter-query-parent-6.json\>
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> \<fedexadgroupcampaign.txt\>\<distance-filter-query-parent-6.json\>\<distance-filter-query-parent-7.json\>\<campaign\_adgrp\_schema.json\>\<0\_comcast.txt\>

---

<div class="post-metadata">

### Author: ![Deep\_2](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Deep\_2](https://discuss.elastic.co/u/Deep_2)
#### Post date: [May 27, 2013, 6:18pm UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/7 "2013-05-27T18:18:23Z")

</div>

Hi David,

Thanks for your input.

To avoid routing issues I have configured only 1 shard. I am assuming that  
with 1 shard \_routing parameter will not have any impact.

Can you please help me with the query in the attached file? Query in the  
has\_parent section is overridden by the nested filter specified below.

Regards,  
Deep

On Monday, 27 May 2013 18:58:00 UTC+5:30, David Pilato wrote:

> Hi Deep,
> 
> If you want to fix routing value, then you have to send all children to  
> the same shard than parent. So use the same \_routing parameter for all  
> documents.  
> If you set for parent a custom routing value, then you have to set the  
> same one for all children.
> 
> HTH
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 26 mai 2013 à 21:11, Deep \<[ishwa...@gmail.com](mailto:ishwa...@gmail.com) \<javascript:\>\> a écrit :
> 
> Hi David,
> 
> Although I am not sure but it seems that the issue is due to routing  
> value. Just keeping 1 shard and got my query partially running.
> 
> The complete list of commands to reproduce the issue are:
> 
> //create schema definition  
> curl -XPOST [http://localhost:9200/ads](http://localhost:9200/ads) -d@campaign\_adgrp\_schema.json
> 
> //load data  
> curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary  
> @./fedexadgroupcampaign.txt  
> curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary  
> @./0\_comcat.txt
> 
> //search in these queries the explain shows that match for kwtargeting is  
> not working. the query needs to be fixed  
> curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)"  
> -d@./distance-filter-query-parent-6.json  
> curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)"  
> -d@./distance-filter-query-parent-7.json
> 
> Looking forward to hear from you soon.  
> Regards,  
> Deep
> 
> On Sunday, 26 May 2013 17:43:56 UTC+5:30, David Pilato wrote:
> 
> > Did you read the help page?  
> > Please gist a full curl recreation (something we can easily replay from  
> > scratch) and we will be happy to help.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 26 mai 2013 à 13:51, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > 
> > Hi David,  
> > Thank you for your response.
> > 
> > I read thru the explain api documentation but it does not seem to help if  
> > the query does not return any results.
> > 
> > If you could help me with the query it would be highly appreciated.
> > 
> > I have attached my schema , dummy data and query file. I want to return  
> > all ads for which the in the parent all the targeting parameters in the  
> > parent adgroup are met (adgroup must be active, keyword must exist in  
> > kwtargetting and the publisher budget must be \> 0 for a publisher).
> > 
> > Thanks
> > 
> > On Sunday, 26 May 2013 14:23:33 UTC+5:30, David Pilato wrote:
> > 
> > > You can use explain API:  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/explain/)
> > > 
> > > Or ask here for advices. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 26 mai 2013 à 10:00, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > > 
> > > Hi ,
> > > 
> > > I need help to debug my query in Elasticsearch. I have a parent / child  
> > > relationship. My query is not returning any results. How can I debug issue  
> > > the issue?
> > > 
> > > Regards,
> > > 
> > > --  
> > > 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).  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > \<campaign\_adgrp\_schema.json\>  
> > \<distance-filter-query-parent-6.json\>
> 
> --  
> 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:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> \<fedexadgroupcampaign.txt\>\<distance-filter-query-parent-6.json\>  
> \<distance-filter-query-parent-7.json\>\<campaign\_adgrp\_schema.json\>  
> \<0\_comcast.txt\>

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Deep\_2](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Deep\_2](https://discuss.elastic.co/u/Deep_2)
#### Post date: [May 28, 2013, 8:14pm UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/8 "2013-05-28T20:14:32Z")

</div>

Hi David,

I was able to fix the issue in the query. But the query does not return any  
results when I increase the number of shards to 5. It works only when the  
number of shards is 1.

Can you please give me pointers as to what could be the issue?  
Regards,  
Deep

On Monday, 27 May 2013 23:48:23 UTC+5:30, Deep wrote:

> Hi David,
> 
> Thanks for your input.
> 
> To avoid routing issues I have configured only 1 shard. I am assuming that  
> with 1 shard \_routing parameter will not have any impact.
> 
> Can you please help me with the query in the attached file? Query in the  
> has\_parent section is overridden by the nested filter specified below.
> 
> Regards,  
> Deep
> 
> On Monday, 27 May 2013 18:58:00 UTC+5:30, David Pilato wrote:
> 
> > Hi Deep,
> > 
> > If you want to fix routing value, then you have to send all children to  
> > the same shard than parent. So use the same \_routing parameter for all  
> > documents.  
> > If you set for parent a custom routing value, then you have to set the  
> > same one for all children.
> > 
> > HTH
> > 
> > --  
> > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> > | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> > 
> > Le 26 mai 2013 à 21:11, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > 
> > Hi David,
> > 
> > Although I am not sure but it seems that the issue is due to routing  
> > value. Just keeping 1 shard and got my query partially running.
> > 
> > The complete list of commands to reproduce the issue are:
> > 
> > //create schema definition  
> > curl -XPOST [http://localhost:9200/ads](http://localhost:9200/ads) -d@campaign\_adgrp\_schema.json
> > 
> > //load data  
> > curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary  
> > @./fedexadgroupcampaign.txt  
> > curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary  
> > @./0\_comcat.txt
> > 
> > //search in these queries the explain shows that match for kwtargeting is  
> > not working. the query needs to be fixed  
> > curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)"  
> > -d@./distance-filter-query-parent-6.json  
> > curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)"  
> > -d@./distance-filter-query-parent-7.json
> > 
> > Looking forward to hear from you soon.  
> > Regards,  
> > Deep
> > 
> > On Sunday, 26 May 2013 17:43:56 UTC+5:30, David Pilato wrote:
> > 
> > > Did you read the help page?  
> > > Please gist a full curl recreation (something we can easily replay from  
> > > scratch) and we will be happy to help.
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 26 mai 2013 à 13:51, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > > 
> > > Hi David,  
> > > Thank you for your response.
> > > 
> > > I read thru the explain api documentation but it does not seem to help  
> > > if the query does not return any results.
> > > 
> > > If you could help me with the query it would be highly appreciated.
> > > 
> > > I have attached my schema , dummy data and query file. I want to return  
> > > all ads for which the in the parent all the targeting parameters in the  
> > > parent adgroup are met (adgroup must be active, keyword must exist in  
> > > kwtargetting and the publisher budget must be \> 0 for a publisher).
> > > 
> > > Thanks
> > > 
> > > On Sunday, 26 May 2013 14:23:33 UTC+5:30, David Pilato wrote:
> > > 
> > > > You can use explain API:  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/explain/)
> > > > 
> > > > Or ask here for advices. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)
> > > > 
> > > > --  
> > > > David 😉  
> > > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > > 
> > > > Le 26 mai 2013 à 10:00, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > > > 
> > > > Hi ,
> > > > 
> > > > I need help to debug my query in Elasticsearch. I have a parent /  
> > > > child relationship. My query is not returning any results. How can I debug  
> > > > issue the issue?
> > > > 
> > > > Regards,
> > > > 
> > > > --  
> > > > 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).  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > 
> > > \<campaign\_adgrp\_schema.json\>  
> > > \<distance-filter-query-parent-6.json\>
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > \<fedexadgroupcampaign.txt\>\<distance-filter-query-parent-6.json\>  
> > \<distance-filter-query-parent-7.json\>\<campaign\_adgrp\_schema.json\>  
> > \<0\_comcast.txt\>

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 29, 2013, 7:14am UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/9 "2013-05-29T07:14:58Z")

</div>

So can you provide a simple curl recreation (Gist it)?  
The best option is to simplify your Gist (no need to have properties you don't query, no need to bulk index but only index few docs - one could be enough).

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 28 mai 2013 à 22:14, Deep [ishwardeep@gmail.com](mailto:ishwardeep@gmail.com) a écrit :

> Hi David,
> 
> I was able to fix the issue in the query. But the query does not return any results when I increase the number of shards to 5. It works only when the number of shards is 1.
> 
> Can you please give me pointers as to what could be the issue?  
> Regards,  
> Deep
> 
> On Monday, 27 May 2013 23:48:23 UTC+5:30, Deep wrote:
> 
> > Hi David,
> > 
> > Thanks for your input.
> > 
> > To avoid routing issues I have configured only 1 shard. I am assuming that with 1 shard \_routing parameter will not have any impact.
> > 
> > Can you please help me with the query in the attached file? Query in the has\_parent section is overridden by the nested filter specified below.
> > 
> > Regards,  
> > Deep
> > 
> > On Monday, 27 May 2013 18:58:00 UTC+5:30, David Pilato wrote:
> > 
> > > Hi Deep,
> > > 
> > > If you want to fix routing value, then you have to send all children to the same shard than parent. So use the same \_routing parameter for all documents.  
> > > If you set for parent a custom routing value, then you have to set the same one for all children.
> > > 
> > > HTH
> > > 
> > > --  
> > > David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
> > > @dadoonet | @elasticsearchfr | @scrutmydocs
> > > 
> > > Le 26 mai 2013 à 21:11, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > > 
> > > > Hi David,
> > > > 
> > > > Although I am not sure but it seems that the issue is due to routing value. Just keeping 1 shard and got my query partially running.
> > > > 
> > > > The complete list of commands to reproduce the issue are:
> > > > 
> > > > //create schema definition  
> > > > curl -XPOST [http://localhost:9200/ads](http://localhost:9200/ads) -d@campaign\_adgrp\_schema.json
> > > > 
> > > > //load data  
> > > > curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary @./fedexadgroupcampaign.txt  
> > > > curl -XPOST [http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty) --data-binary @./0\_comcat.txt
> > > > 
> > > > //search in these queries the explain shows that match for kwtargeting is not working. the query needs to be fixed  
> > > > curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)" -d@./distance-filter-query-parent-6.json  
> > > > curl -XPOST "[http://localhost:9200/ads/ad/\_search?pretty&explain](http://localhost:9200/ads/ad/_search?pretty&explain)" -d@./distance-filter-query-parent-7.json
> > > > 
> > > > Looking forward to hear from you soon.  
> > > > Regards,  
> > > > Deep
> > > > 
> > > > On Sunday, 26 May 2013 17:43:56 UTC+5:30, David Pilato wrote:
> > > > 
> > > > > Did you read the help page?  
> > > > > Please gist a full curl recreation (something we can easily replay from scratch) and we will be happy to help.
> > > > > 
> > > > > --  
> > > > > David 😉  
> > > > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > > > 
> > > > > Le 26 mai 2013 à 13:51, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > > > > 
> > > > > Hi David,  
> > > > > Thank you for your response.
> > > > > 
> > > > > I read thru the explain api documentation but it does not seem to help if the query does not return any results.
> > > > > 
> > > > > If you could help me with the query it would be highly appreciated.
> > > > > 
> > > > > I have attached my schema , dummy data and query file. I want to return all ads for which the in the parent all the targeting parameters in the parent adgroup are met (adgroup must be active, keyword must exist in kwtargetting and the publisher budget must be \> 0 for a publisher).
> > > > > 
> > > > > Thanks
> > > > > 
> > > > > On Sunday, 26 May 2013 14:23:33 UTC+5:30, David Pilato wrote:
> > > > > 
> > > > > > You can use explain API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/explain/)
> > > > > > 
> > > > > > Or ask here for advices. See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)
> > > > > > 
> > > > > > --  
> > > > > > David 😉  
> > > > > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > > > > 
> > > > > > Le 26 mai 2013 à 10:00, Deep [ishwa...@gmail.com](mailto:ishwa...@gmail.com) a écrit :
> > > > > > 
> > > > > > Hi ,
> > > > > > 
> > > > > > I need help to debug my query in Elasticsearch. I have a parent / child relationship. My query is not returning any results. How can I debug issue the issue?
> > > > > > 
> > > > > > Regards,
> > > > > > 
> > > > > > --  
> > > > > > 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).  
> > > > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > > 
> > > > > \<campaign\_adgrp\_schema.json\>  
> > > > > \<distance-filter-query-parent-6.json\>
> > > > 
> > > > --  
> > > > 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).  
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > 
> > > > \<fedexadgroupcampaign.txt\>\<distance-filter-query-parent-6.json\>\<distance-filter-query-parent-7.json\>\<campaign\_adgrp\_schema.json\>\<0\_comcast.txt\>
> 
> --  
> 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).  
> 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).  
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, 2:34am UTC](https://discuss.elastic.co/t/how-to-debug-queries-in-elastic-search/12125/10 "2017-07-06T02:34:13Z")

</div>


