# Nested query within single index

**URL:** <https://discuss.elastic.co/t/nested-query-within-single-index/244937>\
**Category:** Elasticsearch\
**Created:** [August 13, 2020, 6:49pm UTC](https://discuss.elastic.co/t/nested-query-within-single-index/244937 "2020-08-13T18:49:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![j3grewal](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@j3grewal](https://discuss.elastic.co/u/j3grewal)\
**Post date:** [August 13, 2020, 6:49pm UTC](https://discuss.elastic.co/t/nested-query-within-single-index/244937/1 "2020-08-13T18:49:46Z")

</div>

Hi,

Is there support for nested queries within a single index.

I'll try to explain in SQL terms what I am trying to achieve in Elasticsearch:

Say mytable has these columns: name, type, value fields in it. There can be multiple types with their own values for one name. I am trying to query:

`select name, type, value from mytable where type='someType' and name in (select name from mytable where type='someOtherType')`

Note that I am not worried about performance as the data set I am dealing with is fairly small.

Thanks for help.

-Jas

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 18, 2020, 5:52am UTC](https://discuss.elastic.co/t/nested-query-within-single-index/244937/2 "2020-08-18T05:52:13Z")

</div>

What you are showing is a subselect, which is a type of join. Joins are not supported by Elasticsearch so I do not think what you are trying to achieve is possible within a single request.

---

<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:** [September 15, 2020, 5:52am UTC](https://discuss.elastic.co/t/nested-query-within-single-index/244937/3 "2020-09-15T05:52:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
