title: Hibernate search , querying on associations
body: <p>I am new to Hibernate search , can anyone suggest me how to query on Embedded entities (one to many)</p>
  
  <pre><code>@Indexed
  @Entity
  public class EventDetails implements Serializable 
  {
      @OneToMany( cascade = CascadeType.ALL )
      @IndexedEmbedded
      @JoinColumn( name = "event_id" )
      private Set&lt;Batches&gt; batches;
  
      --setter and getter--
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Entity
  @Indexed
  public class Batches 
  {
      @Column( name = "batch" )
      private String batch;
  
      @ManyToOne
      @ContainedIn(mappedBy="batches")
      private EventDetails eventDetails;
  
      --setter and getter--
  }
  </code></pre>
  
  <p>Service class </p>
  
  <pre><code>public List&lt;EventDetails&gt; search()
  {
  fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(getEntityManager());
      QueryBuilder q = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(EventDetails.class).get();
      org.apache.lucene.search.Query luceneQuery = q.keyword().wildcard().onField("").matching(text).createQuery();
      javax.persistence.Query jpaQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, EventDetails.class);
      List&lt;EventDetails&gt; list = jpaQuery.getResultList();
   return list;
  }
  </code></pre>
  
  <p>Now if i have to implement a full text query on "batch" property in batches table , what should i pass as a parameter to the "onField()" method in my service??</p>
  
  <p>Thanks !</p>