Created
March 1, 2013 15:18
-
-
Save kenton/5065305 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::Sunspot::Setup.configure do | |
searchable auto_index: true, | |
auto_remove: true, | |
if: proc { |prod| | |
prod.variants.collect { |var| | |
var.flash_sales.size > 0 && var.flash_sales.any? { |fs| !fs.expired? } | |
}.any? | |
} do | |
text :name, boost: 2.0 | |
text :description, boost: 1.2 | |
text :taxon_labels, boost: 4.0 do | |
taxons.collect{ |t| t.self_and_ancestors.map(&:name) }.flatten | |
end | |
time :available_on | |
integer :taxon_ids, references: Spree::Taxon, multiple: true do | |
taxons.collect{ |t| t.self_and_ancestors.map(&:id) }.flatten | |
end | |
string :taxon_names, multiple: true do | |
taxons.collect{ |t| t.self_and_ancestors.map(&:name) }.flatten | |
end | |
integer :position, references: FlashSaleVariant, multiple: true do | |
variants.collect { |variant| variant.flash_sale_variants.map(&:position) }.flatten | |
end | |
integer :variant_ids, references: Spree::Variant, multiple: true do | |
variants.map(&:id).flatten | |
end | |
integer :flash_sale_ids, references: FlashSale, multiple: true do | |
variants.collect { |variant| variant.flash_sales.map(&:id) }.flatten | |
end | |
time :flash_sale_starts_at, multiple: true do | |
variants.collect { |variant| variant.flash_sales.map(&:starts_at) }.flatten | |
end | |
time :flash_sale_ends_at, multiple: true do | |
variants.collect { |variant| variant.flash_sales.map(&:ends_at) }.flatten | |
end | |
integer :designer_id, references: Designer do | |
designer.id if designer | |
end | |
string :designer_name do | |
designer.name if designer | |
end | |
integer :size, references: Spree::OptionValue, multiple: true do | |
variants.collect{ |variant| variant.option_values.select{ |ov| ["clothing-size","shoes-size"].include?(ov.option_type.name) }.collect{ |ov| ov.id } }.flatten | |
end | |
integer :color, references: Spree::OptionValue, multiple: true do | |
variants.collect{ |variant| variant.option_values.select{ |ov| ov.option_type.name.eql?("color") }.collect{ |ov| ov.id } }.flatten | |
end | |
integer :clothing_size, references: Spree::OptionValue, multiple: true do | |
variants.collect{ |variant| variant.option_values.select{ |ov| ov.option_type.name.eql?("clothing-size") }.collect{ |ov| ov.id } }.flatten | |
end | |
integer :shoes_size, references: Spree::OptionValue, multiple: true do | |
variants.collect{ |variant| variant.option_values.select{ |ov| ov.option_type.name.eql?("shoes-size") }.collect{ |ov| ov.id } }.flatten | |
end | |
integer :condition, references: Spree::OptionValue, multiple: true do | |
variants.collect{ |variant| variant.option_values.select{ |ov| ov.option_type.name.eql?("condition") }.collect{ |ov| ov.id } }.flatten | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment