# Index types connection

**URL:** <https://discuss.elastic.co/t/index-types-connection/6993>\
**Category:** Elasticsearch\
**Created:** [March 14, 2012, 10:44am UTC](https://discuss.elastic.co/t/index-types-connection/6993 "2012-03-14T10:44:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)\
**Post date:** [March 14, 2012, 10:44am UTC](https://discuss.elastic.co/t/index-types-connection/6993/1 "2012-03-14T10:44:12Z")

</div>

Hi,

I have the following problem:  
I have e.g. an index 'documents' and 2 types in it: 'a' (/documents/a)  
and 'b' (/documents/b) that look as follows:  
a:  
{  
"internal\_id" : 'abs12',  
"other\_data" : 'data'  
}

b:  
{  
"internal\_id" : 'abs12',  
"b\_data" : 'other data'  
}

The question is, how to connect these indexes by "internal\_id" so I  
could do the \_search on /documents/a/\_search and get both, documents  
from type 'a' and corresponding documents from type 'b' having the  
same "internal\_id" that the ones from type 'a'. I want to get  
something like a LEFT JOIN b ON a.internal\_id = b.internal\_id in SQL

Thanks for help.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 14, 2012, 10:50am UTC](https://discuss.elastic.co/t/index-types-connection/6993/2 "2012-03-14T10:50:53Z")

</div>

Hiya

> I have the following problem:  
> I have e.g. an index 'documents' and 2 types in it: 'a' (/documents/a)  
> and 'b' (/documents/b) that look as follows:  
> a:  
> {  
> "internal\_id" : 'abs12',  
> "other\_data" : 'data'  
> }
> 
> b:  
> {  
> "internal\_id" : 'abs12',  
> "b\_data" : 'other data'  
> }
> 
> The question is, how to connect these indexes by "internal\_id" so I  
> could do the \_search on /documents/a/\_search and get both, documents  
> from type 'a' and corresponding documents from type 'b' having the  
> same "internal\_id" that the ones from type 'a'. I want to get  
> something like a LEFT JOIN b ON a.internal\_id = b.internal\_id in SQL

You can't do this in a single query, unless you know what internal\_id  
you want to retrieve before you run the query.

If you do know the internal\_id before you start, then you can just  
search across multiple types:

/documents/a,b/\_search

clint

---

<div class="post-metadata">

**Author:** ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)\
**Post date:** [March 14, 2012, 11:19am UTC](https://discuss.elastic.co/t/index-types-connection/6993/3 "2012-03-14T11:19:04Z")

</div>

Thanks for the answer.

Best regards.

2012/3/14 Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)

> Hiya
> 
> > I have the following problem:  
> > I have e.g. an index 'documents' and 2 types in it: 'a' (/documents/a)  
> > and 'b' (/documents/b) that look as follows:  
> > a:  
> > {  
> > "internal\_id" : 'abs12',  
> > "other\_data" : 'data'  
> > }
> > 
> > b:  
> > {  
> > "internal\_id" : 'abs12',  
> > "b\_data" : 'other data'  
> > }
> > 
> > The question is, how to connect these indexes by "internal\_id" so I  
> > could do the \_search on /documents/a/\_search and get both, documents  
> > from type 'a' and corresponding documents from type 'b' having the  
> > same "internal\_id" that the ones from type 'a'. I want to get  
> > something like a LEFT JOIN b ON a.internal\_id = b.internal\_id in SQL
> 
> You can't do this in a single query, unless you know what internal\_id  
> you want to retrieve before you run the query.
> 
> If you do know the internal\_id before you start, then you can just  
> search across multiple types:
> 
> /documents/a,b/\_search
> 
> clint

---

<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, 3:36am UTC](https://discuss.elastic.co/t/index-types-connection/6993/4 "2017-07-06T03:36:16Z")

</div>

Closed on July 6, 2017, 3:36am UTC


