Thanks for responding, I didn't know about the :lazy option. Or at least 
I didn't understand how it worked, thanks.

> Imho the highlight method is supposed to return nil when nothing to
> highlight is there. In this case just retrieve the content of the field
> with result.name or doc[:name] if working with Ferret directly.

Ok that's easy enough to do, thanks.

> I just checked with a plain Ferret script and it had no problems
> retrieving field contents that were just a stop word. If we don't
> get this to work there might be an aaf bug, though ;-)

No that's working correctly, I just didn't realize that that wasn't 
loading my models (if the fields were stored).

> What do you mean with 'loading the value directly'?
> 
> If you used aaf's :lazy => true option when searching, aaf would by
> default not query your db in the first place, and only do so if you ask
> for a non-stored field.
> 
> You can read more about this feature there:
> http://www.jkraemer.net/2007/3/26/lazy-loading-with-acts_as_ferret

Thanks I was missing that part. Now it's working, or almost. The on 
trouble spot is that when I highlight my results the models do get 
loaded. I guess is this because FerretResult doesn't have a highlight 
method, and that causes it to load the underlying model.

To get around this I've changed from:

result.highlight(...)

to:

result.model.aaf_index.highlight(result.id, result.model.name...)

After doing that the database is no longer hit when displaying 
highlighted ferret results, but to do that I needed to add 
"attr_accessor :model" to ActsAsFerret > ResultAttributes. Is there a 
better way to do that? If not could you add that attr_accessor to ferret 
proper?

It might also make sense to also add the highlight method to 
FerretResult to avoid the model load, but I'd still like some way to 
access the model class without requiring a model load since I need that 
to generate the right link the the original page for each result.

I hope at least some of that makes sense :)

Thanks again for the great toolkit.

Jesse

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to