I have setup a custom analyzer and in hibernate.cfg.xml i have this
Code:
<property name="hibernate.search.analyzer">com.workscape.hibernate.search.analyzer.ASCIIFoldingAnalyzer</property>
before this if search with "Mun" i couldn't find the person whose name is "Muñiz" but i was finding the person if i typed "Muñ" for the search criteria.
after my custom analyzer the issue is reversed, seems like i need to attach the analyzer to the indexing process too, is that true? if yes, how do i do that? i thought setting the property above will take care of indexing and searching.
I want to be able find that person with both the strings 'mun' or 'muñ', is it possible?
here is my analyzer.
Code:
public class ASCIIFoldingAnalyzer extends Analyzer {
private static final Log log = LogFactory.getLog(ASCIIFoldingAnalyzer.class);
@Override
public TokenStream tokenStream(String fieldName, Reader reader) {
TokenStream result = null;
try {
result = new StandardTokenizer(Version.LUCENE_31, reader);
result = new StandardFilter(Version.LUCENE_31, result);
result = new LowerCaseFilter(Version.LUCENE_31, result);
result = new StopFilter(Version.LUCENE_31, result, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
result = new ASCIIFoldingFilter(result);
} catch (Throwable t) {
log.warn("Error during filtering ", t);
}
if(log.isDebugEnabled()) {
log.debug("Filtered : " + reader.toString());
}
return result;
}
}
Thanks
Srikanth