On 9/5/06, Jean-Christophe Michel <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
> Le 5 sept. 06, à 01:18, David Balmain a écrit :
> > Can you give me an example of what doesn't work? Something like this;
> >
> >     require 'rubygems'
> >     require 'ferret'
> >
> >     i = Ferret::I.new(:default_field => :content)
> >     i << {:content => "here is the content I want to highlight."}
> >
> >     puts i.highlight("content", 0)
>
> In fact this example work. The difference here is that doc is not
> stored in the index though aaf probably. It's probably the reason why I
> don't have a result: even Myclass.ferret_index.doc(12) returns {}.

Ahhhh, of course. Sorry. Jens mentioned that yesterday so I should
have realized. You need to store the field as well as its term vector
:with_positions_offsets if you want to highlight it. The :term_vector
setting is :with_positions_offsets by default in aaf so you only need
to change the :store setting for the field you want to highlight.

By the way, Myclass.ferret_index.doc(12) will always return {}. The
documents are lazy loading now so Myclass.ferret_index.doc(12)[:id]
will return the model ID. You can load all fields with the load
method. Try;

    puts Myclass.ferret_index.doc(12).load().inspect()

That should show you which fields are actually stored which in the
case of acts_as_ferret will only be the model ID (I think??).

Cheers,
Dave
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to