title: How to use Hibernate Analyzer?
body: <p>I am trying to search for special characters in my hibernate query, I use QueryParser.escape(String searchTerm) to put a '\' character in front of all the special characters to escape them properly.</p>
  
  <p>However I have found out that the standard analyzer used to tokenize removes these special characters from the index, so even if you properly escape the term 'abc-def' if you try and search it you would have to search 'abc def'.  </p>
  
  <p>So what analyzer should I use/how should I specify for the analyzer not to remove the special character when indexing?</p>
  
  <p>A snippet of my annotated class and query building below:</p>
  
  <pre><code>@Entity
  @Table(name="jobReq")
  @Indexed
  public class JobReq {
  
  @Id
  @DocumentId
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private Integer id;
  
  @Field
  @Column(name="jobId", nullable=false, unique=true)
  private String jobId;
  
  @Fields({@Field, @Field(name = "jobIdSort", analyze = Analyze.NO)})
  @Column(name="jobIdSort", nullable=false, unique=true)
  private String jobIdSort;
  
  @Field
  @Column(name="jobTitle", nullable=false)
  private String jobTitle;
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>tempQ = (org.apache.lucene.search.Query) qb.keyword()
                                  .wildcard()
                                  .onField(allFields[i].getName().toString())
                                  .matching(QueryParser.escape(termToFind) + "*")
                                  .createQuery();
                      }   
                      bq.add(new BooleanClause(tempQ, BooleanClause.Occur.SHOULD));
                  }
              }
          }
          //wrap Lucene query in an org.hibernate.Query
          hibQuery = fullTextSession.createFullTextQuery(bq, this.type).setSort(sort);
          results = hibQuery.list();
          System.out.println(bq);
          fullTextSession.getTransaction().commit();
  </code></pre>