简体   繁体   中英

Hibernate search Lucene accent insensitive search

I'm working on a J2E application with an Hibernate Search / Lucene intégration. I index Documents (and other entities) and want to make accent insensitive search on it (content and classes' fields).

I'm using the FrenchAnalyzer which is seems to be Case insensitive (that's good), but i'm surprised to see he doesn't do the same with accent...

After some search and documentation reading, I understand I have to implement my own analyzer, based on the French one and include a filter (the ASCIIFoldingFilter seems to be the one I need).

If I'm right, this means this customAnalyzer have to be applied on the Class index and on the queries. The result will be an index without accents.

Is that the good way todo ? Is there no param or conf attribute for the FrenchAnalyzer to ignore accents ?

thanks

Yes, that's the correct thing to do, and no, FrenchAnalyzer doesn't have any parameters you could pass it to ignore accents. Analyzers usually don't.

The Analyzer API is intended to be easy to implement on, and so often analyzers don't have a lot of configuration settings and such, I believe on the assumption that if you need to customize it's behavior, you can always just copy the one you want to customize and modify it yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM