This is important and may be affecting you if you use :select to minimize the columns you need on big queries. If you use :select to define which columns you need and you have not included all the columns you defined in the :acts_as_ferret field definitions you''ll clear the content of those fields on the ferret index. And that may corrupt your index. So, if you have in your model: Class Blog ... acts_as_ferret :fields => { :title => {:boost => 2}, :sub_title => {}, :url => {} } End You''ll have issues if you do this: b = Blog.find(:first, :select => "id, author") b.save If you want to use :select, you must include the fields AAF needs, like this: b = Blog.find(:first, :select => "id, author, title, sub_title, url") b.save []s -- Posted via http://www.ruby-forum.com/.
Wow, that is a very significant issue. Just to clarify: will saving the object _overwrite_ previously indexed columns? On Apr 1, 2007, at 3:29 PM, Manoel Lemos wrote:> This is important and may be affecting you if you use :select to > minimize the columns you need on big queries. > > If you use :select to define which columns you need and you have not > included all the columns you defined in the :acts_as_ferret field > definitions you''ll clear the content of those fields on the ferret > index. And that may corrupt your index. > > So, if you have in your model: > > Class Blog ... > acts_as_ferret :fields => { :title => {:boost => > 2}, > :sub_title => {}, > :url => {} } > End > > You''ll have issues if you do this: > > b = Blog.find(:first, :select => "id, author") > b.save > > If you want to use :select, you must include the fields AAF needs, > like > this: > > b = Blog.find(:first, :select => "id, author, title, sub_title, url") > b.save > > []s > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk
John Bachir wrote:> Wow, that is a very significant issue. > > Just to clarify: will saving the object _overwrite_ previously > indexed columns?Yep, in my case I was just updating a unique field in my whole database and that cleared my index. -- Posted via http://www.ruby-forum.com/.
On Sun, Apr 01, 2007 at 10:40:57PM +0200, Manoel Lemos wrote:> John Bachir wrote: > > Wow, that is a very significant issue. > > > > Just to clarify: will saving the object _overwrite_ previously > > indexed columns? > > Yep, in my case I was just updating a unique field in my whole database > and that cleared my index.that''s how Ferret works - you just can''t update a document once it has been indexed - aaf simulates updates by deleting the old version and adding a new version based on the record''s data as it is saved. If anybody knows a way to find out that a record is not fully loaded because of a :select option was present when it was found, a fix for this would be easy. Jens -- Jens Kr?mer webit! Gesellschaft f?r neue Medien mbH Schnorrstra?e 76 | 01069 Dresden Telefon +49 351 46766-0 | Telefax +49 351 46766-66 kraemer at webit.de | www.webit.de Amtsgericht Dresden | HRB 15422 GF Sven Haubold, Hagen Malessa
Jens, There is an easy way to fully load a record when it is not fully loaded already. However, I don''t know if this is something nice to have as a default on AAF, since being able to select fields is always good, imagine reloading big BLOBS everytime you change something and you just want to update the record name and description. Maybe you should add a configuration on the field definition, if :auto_reload => :yes, it will do automatically the full load. model_object.reload will do the job. []s Manoel -- Posted via http://www.ruby-forum.com/.
On Mon, Apr 02, 2007 at 01:58:24PM +0200, Manoel Lemos wrote:> Jens, > > There is an easy way to fully load a record when it is not fully loaded > already. > However, I don''t know if this is something nice to have as a default on > AAF, since being able to select fields is always good, imagine reloading > big BLOBS everytime you change something and you just want to update the > record name and description. > > Maybe you should add a configuration on the field definition, if > :auto_reload => :yes, it will do automatically the full load. > > model_object.reload will do the job.well, I knew of that but of course I only wanted to do the reload if the record has not been fully loaded initially. What about that: You could override the to_doc instance method to check if your record has been completely loaded, and if not, call reload, and then call super. However if you always need to reload your record this way, you''d better not use :select in the first place and save you the hassles. Jens -- Jens Kr?mer webit! Gesellschaft f?r neue Medien mbH Schnorrstra?e 76 | 01069 Dresden Telefon +49 351 46766-0 | Telefax +49 351 46766-66 kraemer at webit.de | www.webit.de Amtsgericht Dresden | HRB 15422 GF Sven Haubold, Hagen Malessa
Hi Jens, sorry, i didn''t understood your question at the begin. -- Posted via http://www.ruby-forum.com/.
On Apr 2, 2007, at 7:44 AM, Jens Kraemer wrote:> If anybody knows a way to find out that a record is not fully loaded > because of a :select option was present when it was found, a fix for > this would be easy. >Do you mean, to find out which fields _were_ loaded, and then only reindex those, maintaining the other previously indexed fields? Is that possible? j
On Apr 2, 2007, at 2:54 PM, John Bachir wrote:> On Apr 2, 2007, at 7:44 AM, Jens Kraemer wrote: >> If anybody knows a way to find out that a record is not fully loaded >> because of a :select option was present when it was found, a fix for >> this would be easy. > Do you mean, to find out which fields _were_ loaded, and then only > reindex those, maintaining the other previously indexed fields? Is > that possible?If so, then how about: MyModel.columns.map(&:name) - myobject.attributes.map{ |k,v| k } This will show all of the columns that should NOT be reindexed. But actually, wouldn''t it be easier to ONLY index the columns from: myobject.attributes.map{ |k,v| k } ? Cheers, John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ferret-talk/attachments/20070402/0fc3e34a/attachment-0001.html
On Mon, Apr 02, 2007 at 02:54:27PM -0400, John Bachir wrote:> > On Apr 2, 2007, at 7:44 AM, Jens Kraemer wrote: > > > If anybody knows a way to find out that a record is not fully loaded > > because of a :select option was present when it was found, a fix for > > this would be easy. > > > > Do you mean, to find out which fields _were_ loaded, and then only > reindex those, maintaining the other previously indexed fields? Is > that possible?No, we''ll have to load the full record from db before indexing it. Jens -- Jens Kr?mer webit! Gesellschaft f?r neue Medien mbH Schnorrstra?e 76 | 01069 Dresden Telefon +49 351 46766-0 | Telefax +49 351 46766-66 kraemer at webit.de | www.webit.de Amtsgericht Dresden | HRB 15422 GF Sven Haubold, Hagen Malessa