Using Delta Indexes for associations in Thinking Sphinx

前端 未结 1 577
时光取名叫无心
时光取名叫无心 2021-01-07 04:28

I have a Product model:

class Product < ActiveRecord::Base
    belongs_to :subcategory

    define_index do

        # fields
        indexes subcategory.         


        
相关标签:
1条回答
  • 2021-01-07 04:59

    Try the following instead:

    def set_product_delta_flag
      Product.update_all ['delta = ?', true], ['subcategory_id = ?', id]
      Product.index_delta
    end
    

    A single SQL statement, a single delta re-indexing. Should perform far better :)

    0 讨论(0)
提交回复
热议问题