Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Better search for minne with Ruby and Solr

Better search for minne with Ruby and Solr

Pepabo tech conference #2 in Fukuoka. #pbtech

Ryutaro Mizokami

July 04, 2015
Tweet

Other Decks in Technology

Transcript

  1. • ϨϓϦέʔγϣϯΛ࣮ߦ NBTUFS TMBWF TVOTQPUJOEFY BQQ BQQ BQQ TMBWF TMBWF

    %BUBCBTF ɿ ɿ શ݅࠶ΠϯσΩγϯάͰ ݕࡧͰ͖ΔΑ͏ʹͳΔ·Ͱ
  2. • ΠϯσΩγϯάλεΫΛΩϡʔΠϯά͢Δ NBTUFS TMBWF BQQ BQQ BQQ TMBWF TMBWF %BUBCBTF

    ɿ ɿ +PC ࡞඼ͷߋ৽ ࡞Ոͷߋ৽ ࠩ෼ΠϯσΩγϯάͰ ݕࡧͰ͖ΔΑ͏ʹͳΔ·Ͱ
  3. • ϨϓϦέʔγϣϯΛ࣮ߦ NBTUFS TMBWF BQQ BQQ BQQ TMBWF TMBWF %BUBCBTF

    ɿ ɿ +PC ࡞඼ͷߋ৽ ࡞Ոͷߋ৽ ࠩ෼ΠϯσΩγϯάͰ ݕࡧͰ͖ΔΑ͏ʹͳΔ·Ͱ
  4. ࡞඼σʔλͷมߋ࣌ʹ ࠩ෼ΠϯσΩγϯάΛߦ͏ # /app/models/item.rb class Item < ActiveRecord::Base after_commit(if: :persisted?)

    {self.delay.perform_index} def perform_index indexable? ? index : remove_from_index end end shops items 0..*
  5. ࡞඼ʹؔ࿈ͨ͠σʔλͷมߋ࣌ʹ ࠩ෼ΠϯσΩγϯάΛߦ͏ # /app/models/shop.rb class Shop < ActiveRecord::Base has_many :items

    after_commit(if: :persisted?) { ItemsIndexing.perform_later(items) } end # /app/jobs/items_indexing.rb class ItemsIndexing < ActiveJob::Base def perform(items) items.find_in_batches(batch_size: 50) do |group| Sunspot.batch { group.each(&:perform_index) } end end end