In my project we are using hibernate search 4.5 with lucene-analyzers and solar.
I provide a text field to my clients. When they type in a phrase I would like to find all User
entities whose names include the given phrase.
For example consider having list of entries in database with following titles:
[ Alan Smith, John Cane, Juno Taylor, Tom Caner Junior ]
jun
should return Juno Taylor
and Tom Caner Junior
an
should return Alan Smith
, John Cane
and Tom Caner Junior
@AnalyzerDef(name = "customanalyzer", tokenizer = @TokenizerDef(factory = WhitespaceTokenizerFactory.class), filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = { @Parameter(name = "language", value = "English") })
})
@Analyzer(definition = "customanalyzer")
public class Student implements Serializable {
@Column(name = "Fname")
@Field(index = Index.YES, store = Store.YES, analyze = Analyze.YES)
private String fname;
@Column(name = "Lname")
@Field(index = Index.YES, store = Store.YES, analyze = Analyze.YES)
private String lname;
}
I have tried with wildcard search but
Query luceneQuery = mythQB
.keyword()
.wildcard()
.onFields("fname")
.matching("ju*")
.createQuery();
How can I achieve this?