title: How to create a query using wildcards and projections with hibernate search?
body: <p>I am trying to create a queries using wildcards and projections with hibernate search, but I'm failing. The users can use or not wildcard on queries. For example, I want to search all terms starting with <strong>"book"</strong>, I use <strong>"book*"</strong> to search.</p>
  
  <p>The method I've implemented, is below.</p>
  
  <pre><code>public List&lt;Employee&gt; filtrar(String term) throws DAOException {
      try {
          FullTextEntityManager fullTextEm = Search.getFullTextEntityManager(this.entityManager);
  
          Query query = new WildcardQuery(new Term("*", term));           
  
          FullTextQuery fullTextQuery = fullTextEm.createFullTextQuery(query, Employee.class);
          fullTextQuery.setProjection("id", "name", "phone", "email");
          Sort sortField = new Sort(new SortField("name_order", SortField.STRING));
          fullTextQuery.setSort(sortField);
          return fullTextQuery.getResultList();
      }
      catch (Exception e) {
          logger.error("Error: " + term, e);
          throw new DAOException(e);
      }
  }
  </code></pre>
  
  <p>The String <code>term</code> passed, as parameter to method, is used to search on all fields(id, name, phone and email). Nothing is returned. What's wrong in that method?</p>
  
  <p><strong>EDIT</strong>: My entity</p>
  
  <pre><code>@Entity
  @Indexed
  @Table(name = "vw_employee")
  public class Employee implements Serializable {
  
      private static final long serialVersionUID = 244555315052436669L;
  
      @Id
      @Column(name = "id", insertable = false, updatable = false)
      @Field(store = Store.YES, index = Index.YES, analyze = Analyze.NO)
      private Long id;
  
      @Fields({
          @Field(name = "name_order", store = Store.YES, index = Index.YES, analyze = Analyze.NO),
          @Field(name = "name", store = Store.YES, index = Index.YES, analyze = Analyze.YES)
      })
      @Column(name = "name", insertable = false, updatable = false)
      private String name;
  
      @Field(store = Store.YES, index = Index.YES, analyze = Analyze.YES)
      @Column(name = "phone", insertable = false, updatable = false)
      private String phone;
  
      @Field(store = Store.YES, index = Index.YES, analyze = Analyze.YES)
      @Column(name = "email", insertable = false, updatable = false)
      private String email;
  
      //Getters and setters ommited
  }
  </code></pre>
  
  <p><strong>Indexing method</strong>:     </p>
  
  <pre><code>public void index() throws DAOException {
          FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(this.entityManager);
  
          try {
              fullTextEntityManager.createIndexer(Employee.class).purgeAllOnStart(Boolean.TRUE).optimizeOnFinish(Boolean.TRUE).startAndWait();
              logger.info("Indexing....");
          }
          catch (InterruptedException e) {
              logger.error("Error", e);
              throw new DAOException(e);
          }
  }
  </code></pre>