bbqTree
2006-Oct-09 13:27 UTC
[Ferret-talk] hello, acts_as_ferret questions, any help greatly appreciate
hi, ive been reading up on ferret, acts_as_ferret, and other search plugins for rails. after reading about ferret, i found out about the acts_as_ferrt plugin. my first question about acts_as_ferret: 1. from reading about ferret, do i still need to manually save the IDX and add a IDX column field to my model table for acts_as_ferret to work? they say that acts_as_ferret handles everything, but i wasnt sure what exactly does it handle when compared to the ferret tutorials that i read. 2. is there a complete tutorial online for acts_as_ferret plugin? so far all the blogs that i came across pretty much say the same thing. 3. does acts_as_ferret do this? if i specify acts_as_ferret to index just title column in my ''recipe'' table, and if someone types ''bbq plate'' in the search box, will these recipes with the following title match? "island bbq style plate" "bbq ribs" "potato plate salad" "my bbq plate" if so, will the one with the most matching text like "my bbq plate" be listed as #1? Thanks for the help! -- Posted via http://www.ruby-forum.com/.
David Balmain
2006-Oct-09 16:22 UTC
[Ferret-talk] hello, acts_as_ferret questions, any help greatly appreciate
On 10/9/06, bbqTree <none at none.com> wrote:> hi, ive been reading up on ferret, acts_as_ferret, and other search > plugins for rails. > > after reading about ferret, i found out about the acts_as_ferrt plugin. > > my first question about acts_as_ferret: > > 1. from reading about ferret, do i still need to manually save the IDX > and add a IDX column field to my model table for acts_as_ferret to work? > they say that acts_as_ferret handles everything, but i wasnt sure what > exactly does it handle when compared to the ferret tutorials that i > read.Personally I don''t use acts_as_ferret but I''ll try and answer these questions as best I can. The following will automatically index the fields of the Foo model: class Foo < ActiveRecord::Base acts_as_ferret end See http://projects.jkraemer.net/acts_as_ferret/wiki/AdvancedUsage for more advanced usage.> 2. is there a complete tutorial online for acts_as_ferret plugin? so far > all the blogs that i came across pretty much say the same thing.That above link is the most complete tutorial I know of. Maybe someone else will know of other resources. If you need to do anything more advanced then you should probably learn more about Ferret itself.> 3. does acts_as_ferret do this? if i specify acts_as_ferret to index > just title column in my ''recipe'' table, and if someone types ''bbq plate'' > in the search box, will these recipes with the following title match? > > "island bbq style plate" > "bbq ribs" > "potato plate salad" > "my bbq plate" > > if so, will the one with the most matching text like "my bbq plate" be > listed as #1?Ferret is pretty easy to experiment with. Here is an example: require ''rubygems'' require ''ferret'' index = Ferret::I.new [ "island bbq style plate", "bbq ribs", "potato plate salad", "my bbq plate" ].each {|text| index << text} puts index.search(''bbq plate'') puts index.search(''"bbq plate"'') And the output: TopDocs: total_hits = 4, max_score = 0.883883 [ 3 "my bbq plate": 0.883883 0 "island bbq style plate": 0.707107 1 "bbq ribs": 0.220971 2 "potato plate salad": 0.176777 ] TopDocs: total_hits = 1, max_score = 1.250000 [ 3 "my bbq plate": 1.250000 ] So to answer your question, yes, the results are ordered by relevency.> Thanks for the help!no problem. Dave
Jens Kraemer
2006-Oct-09 16:22 UTC
[Ferret-talk] hello, acts_as_ferret questions, any help greatly appreciate
On Mon, Oct 09, 2006 at 03:27:34PM +0200, bbqTree wrote:> hi, ive been reading up on ferret, acts_as_ferret, and other search > plugins for rails. > > after reading about ferret, i found out about the acts_as_ferrt plugin. > > my first question about acts_as_ferret: > > 1. from reading about ferret, do i still need to manually save the IDX > and add a IDX column field to my model table for acts_as_ferret to work? > they say that acts_as_ferret handles everything, but i wasnt sure what > exactly does it handle when compared to the ferret tutorials that i > read.I don''t know what that IDX column should be good for, where did you read about that ? basically acts_as_ferret can handle everything for you. just call acts_as_ferret in your model class definition, and you''ll get (besides other goodies and methods for special use cases): - automatic index creation for existing records - new records are automatically added to the index - automatic index updates, when you update your model data - automatic removal of documents from the index when the corresponding model object is destroyed. - Model.find_by_contents(''querystring'') to retrieve model instances matching the querystring. the acts_as_ferret method offers several options to customize the way aaf works, i.e. which fields of your model should get indexed, and with which indexing options (refer to the api docs at http://projects.jkraemer.net/acts_as_ferret/rdoc)> 2. is there a complete tutorial online for acts_as_ferret plugin? so far > all the blogs that i came across pretty much say the same thing.the API docs for the acts_as_ferret and find_by_content methods should get you started. You might also want to check out the demo project from the acts_as_ferret svn (see the wiki at http://projects.jkraemer.net/acts_as_ferret/ for the repository url)> 3. does acts_as_ferret do this? if i specify acts_as_ferret to index > just title column in my ''recipe'' table, and if someone types ''bbq plate'' > in the search box, will these recipes with the following title match? > > "island bbq style plate" > "bbq ribs" > "potato plate salad" > "my bbq plate"since acts_as_ferret defaults to ANDed queries, only records 1 and 4 would match. you can however make aaf use ORed queries by specifying :or_default => false in your call to acts_as_ferret.> if so, will the one with the most matching text like "my bbq plate" be > listed as #1?I suppose it would be #1, not because the exact phrase matches, but because it''s the most relevant hit (the overall size of the text is smaller than that of the other document matching the query, and a match in a short text generally scores higher than one in a large text). Anybody please correct me if I''m wrong here. cheers, Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66