# Sub querying in Elasticsearch

**URL:** <https://discuss.elastic.co/t/sub-querying-in-elasticsearch/9370>\
**Category:** Elasticsearch\
**Created:** [October 16, 2012, 8:33am UTC](https://discuss.elastic.co/t/sub-querying-in-elasticsearch/9370 "2012-10-16T08:33:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [October 16, 2012, 8:33am UTC](https://discuss.elastic.co/t/sub-querying-in-elasticsearch/9370/1 "2012-10-16T08:33:54Z")

</div>

Hi,  
Is it possible in Elasticsearch to use the results of a query to  
another query in a single query?? some sort of subquery in sql??? I need to  
feed back the results of a query to another query, but currently I am  
taking the help of double query, and I can not post the result data more  
than 1024 in query against some field?? So I was thinking if it can be  
managed in the Elasticsearch internally to use the results of a query into  
the another query ??

If anyone knows this, Please help. All of your help or guidance will be  
appreciated.

Thanks

--

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [October 16, 2012, 9:04am UTC](https://discuss.elastic.co/t/sub-querying-in-elasticsearch/9370/2 "2012-10-16T09:04:07Z")

</div>

hey there,

On Tuesday, October 16, 2012 10:33:54 AM UTC+2, Narinder Kaur wrote:

> Hi,  
> Is it possible in Elasticsearch to use the results of a query to  
> another query in a single query?? some sort of subquery in sql??? I need to  
> feed back the results of a query to another query, but currently I am  
> taking the help of double query, and I can not post the result data more  
> than 1024 in query against some field?? So I was thinking if it can be  
> managed in the Elasticsearch internally to use the results of a query into  
> the another query ??

you can't do subqueries like in sql in Elasticsearch the only thing I can  
think of is the More Like This API  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/more-like-this.html) that  
could help here. otehrwise you need to execute two requests anyway.

simon

> If anyone knows this, Please help. All of your help or guidance will be  
> appreciated.
> 
> Thanks

--

---

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [October 16, 2012, 9:37am UTC](https://discuss.elastic.co/t/sub-querying-in-elasticsearch/9370/3 "2012-10-16T09:37:44Z")

</div>

Thanks for the help. I will try this out

On Tuesday, 16 October 2012 14:34:07 UTC+5:30, simonw wrote:

> hey there,
> 
> On Tuesday, October 16, 2012 10:33:54 AM UTC+2, Narinder Kaur wrote:
> 
> > Hi,  
> > Is it possible in Elasticsearch to use the results of a query to  
> > another query in a single query?? some sort of subquery in sql??? I need to  
> > feed back the results of a query to another query, but currently I am  
> > taking the help of double query, and I can not post the result data more  
> > than 1024 in query against some field?? So I was thinking if it can be  
> > managed in the Elasticsearch internally to use the results of a query into  
> > the another query ??
> 
> you can't do subqueries like in sql in Elasticsearch the only thing I can  
> think of is the More Like This API  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/more-like-this.html) that  
> could help here. otehrwise you need to execute two requests anyway.
> 
> simon
> 
> > If anyone knows this, Please help. All of your help or guidance will be  
> > appreciated.
> > 
> > Thanks

--

---

<div class="post-metadata">

**Author:** ![George\_Diamantidis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/george_diamantidis/32/1165_2.png) [@George\_Diamantidis](https://discuss.elastic.co/u/George_Diamantidis)\
**Post date:** [October 21, 2014, 9:40am UTC](https://discuss.elastic.co/t/sub-querying-in-elasticsearch/9370/4 "2014-10-21T09:40:32Z")

</div>

Hi,  
I cannot find any documentation for sub-querying in the current stable  
1.3.4 version.  
Are there any plans for this in the future?

Thanks,  
George

On Tuesday, 16 October 2012 10:37:44 UTC+1, Narinder Kaur wrote:

> Thanks for the help. I will try this out
> 
> On Tuesday, 16 October 2012 14:34:07 UTC+5:30, simonw wrote:
> 
> > hey there,
> > 
> > On Tuesday, October 16, 2012 10:33:54 AM UTC+2, Narinder Kaur wrote:
> > 
> > > Hi,  
> > > Is it possible in Elasticsearch to use the results of a query to  
> > > another query in a single query?? some sort of subquery in sql??? I need to  
> > > feed back the results of a query to another query, but currently I am  
> > > taking the help of double query, and I can not post the result data more  
> > > than 1024 in query against some field?? So I was thinking if it can be  
> > > managed in the Elasticsearch internally to use the results of a query into  
> > > the another query ??
> > 
> > you can't do subqueries like in sql in Elasticsearch the only thing I can  
> > think of is the More Like This API  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/more-like-this.html)  
> > that could help here. otehrwise you need to execute two requests anyway.
> > 
> > simon
> > 
> > > If anyone knows this, Please help. All of your help or guidance will be  
> > > appreciated.
> > > 
> > > 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/720a3954-a180-4fdf-aced-eb2feba598ad%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/720a3954-a180-4fdf-aced-eb2feba598ad%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:54am UTC](https://discuss.elastic.co/t/sub-querying-in-elasticsearch/9370/5 "2017-07-06T00:54:48Z")

</div>


