Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lucene Search for japanese characters

I have implemented lucene for my application and it works very well unless you have introduced something like japanese characters.

The problem is that if I have japanese string こんにちは、このバイネイです and I search with こ that is the first character than it works well whereas if I use more than one japanese character(こんにち)in search token search fails and there is no document found.

Are japanese characters supported in lucene? what are the settings to be done to get it working?

like image 702
Pranali Desai Avatar asked Apr 15 '10 07:04

Pranali Desai


2 Answers

Built-in analyzer of lucene does not support japanese.

You need to install some analyzer like sen, which is java port of mecab, quite popular japanese analyzer, and its fast.

There is 2 sub types called

  1. CJKAnalyzer, which support chinese, and korean too, and using bi-gram method
  2. JapaneseAnalyzer, which only support japanese, using Morphological Analyzer and supposed to be very fast.
like image 127
YOU Avatar answered Oct 17 '22 14:10

YOU


I don't think there can be an analyzer that will work for all languages. The problem is that different languages have different rules about word boundaries and stemming (for example, the Thai language doesn't use spaces at all to separate words). Or if there is, I certainly wouldn't want to be the maintainer!

What you will need to do is "tag" blocks of text as one language or another and use the correct analyzer for that particular language. You can attempt to detect the language "automatically" by doing character analysis (i.e. text using predominantly Japanese Katakana is likely Japanese)

like image 44
Dean Harding Avatar answered Oct 17 '22 15:10

Dean Harding