Hi,
I have a problem with NGramFilterFactory
NameEn = "Hello everybody TODAY"
For example when i search for "b", it shows me the result
But when i search for "bo" or "bod" or "body", it shows me nothing
Now when i change minGramSize to 2
When i searched for "bo", it shows me the result
And the other key words "b", "bod", "body" it shows me nothing
i do not know where the problem exactly is, because according to the code below, when i entered "bo"
Output will be: "b", "bo"
Code:
@Indexed
@AnalyzerDef(name = "autocompleteNGramAnalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
@TokenFilterDef(factory = WordDelimiterFilterFactory.class),
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = NGramFilterFactory.class, params = {
@Parameter(name = "minGramSize", value = "1"),
@Parameter(name = "maxGramSize", value = "50") }),
@TokenFilterDef(factory = PatternReplaceFilterFactory.class, params = {
@Parameter(name = "pattern", value = "([^a-zA-Z0-9\\.])"),
@Parameter(name = "replacement", value = " "), @Parameter(name = "replace", value = "all") }) })
@Analyzer(definition = "autocompleteNGramAnalyzer")
public class Product implements Serializable {
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
private String nameEn;
Code:
org.apache.lucene.search.Query luceneQuery = queryBuilder.phrase().withSlop(2).onField("nameEn").boostedTo(5).sentence(keyWord.toLowerCase()).createQuery();