Saturday, 15 August 2015

ruby on rails - How do you index records even if some of the columns are nil? -



ruby on rails - How do you index records even if some of the columns are nil? -

i using sunspot/solr search. found records not beingness indexed because column had nil values.

how can tell solr index these records regardless?

this searchable block looks like:

searchable text :name text :description # price_as_double can nil double :price_as_decimal text :colors colors.map(&:name) end text :store unless store.nil? store.name end end string :store unless store.nil? store.name end end text :items_style unless items_style.nil? items_style.name end end time :created_at boolean :editors_pick string :sold_out double :likes end

for rails need add together next function migration

def alter add_column :product, :price, :string add_index :product, :price end

your migration work , allow multiply null values (for database engines).

but validation product class should below.

validates :price, allow_nil: true

ruby-on-rails solr sunspot sunspot-rails

No comments:

Post a Comment