Acts_as_ferret derived fields and custom analyzer

Hello!

I am using the following Analyzer:

require ‘rubygems’
require ‘ferret’
module Ferret
module Analysis
class StemmingAnalyzer < Analyzer

  def initialize(stop_words = FULL_ENGLISH_STOP_WORDS, lower = true)
        @lower = lower
        @stop_words = stop_words
  end

  def token_stream(field, text)
    ts = StandardTokenizer.new(text)
    ts = LowerCaseFilter.new(ts) if @lower
    ts = StopFilter.new(ts, @stop_words)
    ts = HyphenFilter.new(ts)
    StemFilter.new(ts)
  end
end

end
end

And my model looks like:

class Product < ActiveRecord::Base
include UUIDHelper

acts_as_ferret(:fields => [ :name, :description, :category_name],
:remote => true,
:ferret => { :analyzer =>
Ferret::Analysis::StemmingAnalyzer.new },
:store_class_name => true)

validates_presence_of :name, :upc, :ucc_12
validates_presence_of :category_id, :manufacturer_id, :brand_id

validates_length_of :name, :maximum => 50,
:message => ‘is too long. Maximum length is 50
characters.’

validates_length_of :description, :maximum => 255,
:message => ‘is too long. Maximum length is 255
characters.’

belongs_to :category

def category_name
return self.category.name
end

def self.per_page
20
end
end

My problem is that the custom analyzer does not seem to be getting
applied to the “category_name” derived field.

Has anyone else had this problem?

Thank you,
Vivek

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs