How to Tokenize the Input Search String and search individually in Hibernate Search?

Prasath Govind Source

I am using Hibernate Search in my project and able to successfully Index the required Entities.

I am searching for the input string across 3 tables : 1. Person (name) 2. Hobbies (hobby) 3. Skills (techSkill)

If the input is "ben", the Lucene Query generated is below :

Wilcard context : Executing Lucene query 'name:*ben* hobbiesSet.hobby:*ben* skillSet.techSkill:*ben*'

But if I search for "ben tennis", then the Lucene Query is :

Wilcard context : Executing Lucene query 'name:*ben tennis* hobbiesSet.hobby:*ben tennis* skillSet.techSkill:*ben tennis*'

How to search like :

Wilcard context : Executing Lucene query 'name:*ben* hobbiesSet.hobby:*ben* skillSet.techSkill:*ben*' 'name:*tennis* hobbiesSet.hobby:*tennis* skillSet.techSkill:*tennis*' ?

I know using FuzzyContext we can achieve this but I dont want to use FuzzyContext and use only WildcardContext since FuzzyContext has editDistance limitation. How to go about?

Here's my Lucene Analyzer :

@AnalyzerDef(name = "TblResumesAnalyzer",
    tokenizer =  @TokenizerDef(factory = StandardTokenizer.class),
    filters = {
                @TokenFilterDef(factory = LowerCaseFilterFactory.class),
                @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
                @Parameter(name = "language", value = "English")
            })
})
javahibernatesearchlucenehibernate-search

Answers

comments powered by Disqus