I’m not really sure if this is a bug, but it makes my search results
look a bit strange. I have an acts_as_ferret declaration that looks
like:
acts_as_ferret :store_class_name => true, :remote => true, :fields =>
{
:ferret_name => { :store => :yes, :boost => 2 },
:ferret_content => { :store => :yes } }
I store both fields so that I don’t need to load each result model from
the rails DB when displaying the results. This is the code that I use to
show each result:
highlighted_name = result.highlight(params[:q], :field => :ferret_name,
:pre_tag => “”, :post_tag => “”, :excerpt_length =>
150, :num_excerpts => 1)
highlighted_content = result.highlight(params[:q], :field =>
:ferret_content, :pre_tag => “”, :post_tag => “”,
:excerpt_length => 150, :num_excerpts => 1)
Generally this all works fine. The problem happens when the ferret_name
of my model is a word that is skipped by the ferret tokenize. For
example if I have a model with:
ferret_name: about
ferret_content: rails
Then when I do a search for ‘rails’ the result will be found, but the
results highlighted_name will be blank. So I don’t see the name of the
model in the result. This seems to be a special case, because generally
words like “about” and “the” that are skipped by the tokenizer will
still be stored when :store => :yes when they are in a phrase.
I hope that makes some sense. For now I can get around the problem by
checking for the blank case and loading the value from the model
directly, but things would be easier if :store => :yes would just always
store the field value.
Thanks for any help,
Jesse