Its my first time dealing with optimized search functionality, and part of my proficiency is on the front end of android development, but I'm willing to take the adventure of hibernate-search. I do understand the functionality of SQL "LIKE" query, what it does and its limitation, thats the reason why I jumped straight ahead to hibernate-search (lucene), my goal is to have an auto suggestion based on inputs(input queries). This is what I got so far
@Indexed
@Table (name = "shop_table")
@Entity
@AnalyzerDef(name = "myanalyzer",
tokenizer = @TokenizerDef(factory = KeywordTokenizerFactory.class), //
filters = { //
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = WordDelimiterFilterFactory.class),
@TokenFilterDef(factory = EdgeNGramFilterFactory.class, params =
{ @Parameter(name = "maxGramSize", value = "1024") }),})
@Analyzer(definition = "myanalyzer")
public class Shop implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
enter code here
@Field(index = Index.YES, store = Store.YES, analyze = Analyze.YES)
@Column(name = "name")
private String name;
... other methods
My query
Query lucenQuery = qb.keyword().onField("name").matching(searchTerm).createQuery();
Its just a basic query, and I focus solely on the analyzer configuration to get what I want, its really confusing which part should I focus on to achieve what I want, the Tokenizing? the Filtering? or the Query itself? anyway I have these 2 phrases already indexed.
"Apache Lychee Department"
"Apache Strawberry Club Large"
When I process/query "Straw" it gives me the Apache Strawberry Club Large but when I process/query "Lychee" or "Apache Lychee" the query gives me both? Im only expecting Apache Lychee Department
The way I understand all my configuration is/are
EdgeNGramFilterFactory (1024) will give me a series of 1,024 index of EdgeNGrams
LowerCaseFilterFactory will give me all lower-cased indeces
WordDelimiterFilterFactory filter it by making the query as one word, and give me the matching data.
and every entry/data will be tokenized as a Keyword by KeywordTokenizerFactory and will be indexed 1,024 by EdgeNGram
I tried to query a phrase, but still getting the same output
Query luceneQuery = qb.phrase().onField("name").sentence(searchTerm).createQuery();
My Goal is to have an auto-suggestion.. or atleast start with mimicking "LIKE" of sql..