Chinese full text searching by acts_as_ferret?

How to add Chinese language full text searching function by using
acts_as_ferret?

RegExpAnalyzer.new(/./,false)

this analyzer, i don’t know how to use it!
does it works like this:

user searching---->acts_as_ferret---->ferret
???

On Thu, Apr 19, 2007 at 10:06:16AM +0200, Chengcai He wrote:

How to add Chinese language full text searching function by using
acts_as_ferret?

RegExpAnalyzer.new(/./,false)

this analyzer, i don’t know how to use it!
does it works like this:

user searching---->acts_as_ferret---->ferret

basically, yes.

You can tell acts_as_ferret what analyzer to use with the :analyzer
option in the second options hash:

class MyModel
acts_as_ferret { :fields => { … } }, { :analyzer =>
RegExpAnalyzer.new }

end

background info: the first options hash are acts_as_ferret options, and
the second options hash is passed through to Ferret’s Index class.

Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa

in environment.rb, i add the following code
$KCODE = ‘u’
require ‘jcode’
ENV[‘LANG’] = ‘en_US.utf8’
require ‘acts_as_ferret’

in my model, topic.rb
acts_as_ferret :fields => [:subject, :body], :analyzer =>
Ferret::Analysis::RegExpAnalyzer.new(/./,false)

it doesn’t work when i input the chinese word to search!

I don’t know how to do!

Hello everyone!

I use the ferret as the following:
acts_as_ferret :fields => [:subject, :body], :analyzer =>
Ferret::Analysis::RegExpAnalyzer.new(/./,false)

when i input the english word to search, it’s so cool and so soon to got
the result! but when i input the chinese words to search, the ruby
allocate all the memory and the computer has no response, after a long
long time wait, there’s a exception: failed to allocate memory! In the
log file: Adding field body with value ‘中文文问’, it’s true that ferret add
the chinese text into the index, but i can not search chinese words!

I don’t know how to deal with this!

i would also be very grateful as well if someone could provide an
analyzer for chinese text, or some hints how to build one. the
StandardAnalyzer ignores all chinese glyphs.
cheers, phillip

On Thu, Apr 19, 2007 at 03:49:48PM +0200, Chengcai He wrote:

in environment.rb, i add the following code
$KCODE = ‘u’
require ‘jcode’
ENV[‘LANG’] = ‘en_US.utf8’
require ‘acts_as_ferret’

in my model, topic.rb
acts_as_ferret :fields => [:subject, :body], :analyzer =>
Ferret::Analysis::RegExpAnalyzer.new(/./,false)

to make aaf use your analyzer, please format the call like this:

acts_as_ferret { :fields => [:subject, :body] },
{ :analyzer =>
Ferret::Analysis::RegExpAnalyzer.new(/./,false) }

I’m seriously thinking about an API change because people always mix
up the two hashes.

Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa