Hibernate Search | ngram analyzer with minGramSize 1

Updated answer for Hibernate Search 6 With Hibernate Search 6, you can define a second analyzer, identical to your “ngram” analyzer except that it does not have an ngram filter, and assign it as the searchAnalyzer for your field: public class Hospital { // … @FullTextField(analyzer = “ngram”, searchAnalyzer = “my_analyzer_without_ngrams”) private String name = … Read more

Hibernate Search: How to use wildcards correctly?

Updated answer for Hibernate Search 6 Short answer: don’t use wildcard queries, use a custom analyzer with an EdgeNGramFilterFactory. Also, don’t try to analyze the query yourself (that’s what you did by splitting the query into terms): Lucene will do it much better (with a WhitespaceTokenizerFactory, an ASCIIFoldingFilterFactory and a LowercaseFilterFactory in particular). Long answer: … Read more