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:
On Sun, Apr 01, 2007 at 10:40:57PM +0200, Manoel L. wrote:
John B. 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 [email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
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.
On Mon, Apr 02, 2007 at 01:58:24PM +0200, Manoel L. wrote:
: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 [email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
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 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: