On Tue, Aug 14, 2007 at 04:51:59AM +0200, Allen Young wrote:
> Jens Kraemer wrote:
> > I'd just rescue that and return nil for the field:
> > 
> >    Property2.ferret_fields.keys.each do |field|
> >      define_method("#{field}") do
> >        result = property.send("#{field}") rescue nil
> >      end
> >    end
> > 
> For now, I'm rescuing the "NoMethodError" which works fine as well.
> 
> >> 2. Say "Property1" has 500 fields as well as "Property2", each product
> >> will be indexed using 1000 fields while only at most 500 fields contains
> >> value.
> > 
> > Do you really need to be able to run queries against each single one of
> > these 1000 fields? If not, you could concatenate their values into a
> > single large :properties field.
> I'm afraid so... because many of these fields are number fields and 
> users will want to search these fields like "field1 is bigger than 1.5 
> and smaller than 0.7".

Ok. To avoid the 500 nil fields per record you could override the to_doc 
instance method in your model and only add the relevant fields depending 
on the type of your property. The original implementation is in 
acts_as_ferret's 
instance_methods.rb .


Jens

-- 
Jens Krämer
http://www.jkraemer.net/ - Blog
http://www.omdb.org/     - The new free film database
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to