On 9/4/06, Jean-Christophe Michel <[EMAIL PROTECTED]> wrote:
> Hi Dave,
>
> Le 3 sept. 06, à 15:26, David Balmain a écrit :
> > I've added a highlight method to Ferret::Index::Index so you'll be
> > able to use it now.
>
> Thanks. Trying to use this, I updated to 0.10.2 gem.
> But I cannot get highlight return something else than nil.
> I suspect highly the doc id not always being my indexed class id,
> though aaf code seems to create docs with Model.id :/
>
> I tried to do
>   i.search 'rare_word'
>   Mymodel.find result-id # contains no such word
>   i.highlight('rare_word', result-id, :field => :myfield)
>
> But if I try to pass a model id containing this word for sure, I still
> get nil result :/
>   i.highlight('rare_word', model-id, :field => :myfield)
>
> I'll try to turn this into a test case in aaf.
>
> --
> Jean-Christophe Michel

Try this;

    index.search_each(query) do |doc_id, score|
        puts index.highlight(query, doc_id, :field => :my_field).join(", ")
    end

Also, I think you should be doing something like this to get the
resulting object from the database;

    MyModel.find index[doc_id][:id]

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

Reply via email to