# Joining Two Indexes

**URL:** <https://discourse.hibernate.org/t/joining-two-indexes/2366>\
**Category:** Hibernate Search\
**Created:** [February 26, 2019, 8:04am UTC](https://discourse.hibernate.org/t/joining-two-indexes/2366 "2019-02-26T08:04:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GauravK](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@GauravK](https://discourse.hibernate.org/u/GauravK)\
**Post date:** [February 26, 2019, 8:04am UTC](https://discourse.hibernate.org/t/joining-two-indexes/2366/1 "2019-02-26T08:04:59Z")

</div>

We are having two index corresponding to two entities:

@Entity  
@Table(name = “A”)  
@Indexed(index=“a”)  
public class A{  
}

@Entity  
@Table(name = “B”)  
@Indexed(index=“B”)  
public class B{  
}

Is it possible to create a join in the query to retrieve result from both index by joining on some common identifier?

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [February 26, 2019, 9:48am UTC](https://discourse.hibernate.org/t/joining-two-indexes/2366/2 "2019-02-26T09:48:02Z")

</div>

You can target both indexes in a single query, so as to retrieve results of type A or B in the same result list:

```auto
FullTextQuery query = fullTextEntityManager.createQuery( luceneQuery, A.class, B.class );
List<Object> results = query.getResultList(); // Contains some objects of type A and some objects of type B

```

But if you really want a join, then no, Hibernate Search does not provide that feature. Multi-entity queries are generally achieved with `@IndexedEmbedded`, by embedding other entities in an entity’s index. See [this section of the documentation](https://docs.jboss.org/hibernate/search/5.11/reference/en-US/html_single/#search-mapping-associated).
