1

I am a newbie to elastic Search and Tire in Ruby on Rails. Watched the railscasts from ryan bates and helped me to get going. Tire is a great gem and has functionality to delta indexing. Assuming i have a mapping like the following, will Tire automatically delta index the model associations if an association value is edited/ deleted. For Example, Assume i have index mapping like the following,

 mapping do
    indexes :id,      :type => 'integer', :index    => :not_analyzed
    indexes :col_2,   :type => 'integer', :index    => :not_analyzed
    indexes :col_3,   :type => 'date'
    indexes :col_4,   :type => 'date'

    indexes :model_2 do
      indexes :name,                  :type => 'string', :analyzer => 'whitespace'
      indexes :association_col_2,     :type => 'string', :index    => :not_analyzed
    end
 end

When the value of model_2.association_col_2 changes will tire automatically delta index the corresponding row in the model defined the mapping for ? How should i approach delta indexing the model on association model value changes ?

Thanks in advance

4

1 に答える 1

0

タイヤは例えばとは異なります。Sphinxを考えると、実際にはデルタインデックスが発生していないため、モデルが変更され、インデックスコールバックが含まれている場合、 JSONにシリアル化されたレコード全体がelasticsearchに送信され、古いドキュメントが置き換えられます(elasticsearchは実際には「検索可能なドキュメントデータベース」)。

子モデルから親モデルでコールバックをトリガーする場合は、そのためにRailsをインストルメント化する必要があります。

class Brake < ActiveRecord::Base
  belongs_to :car, :touch => true
end

ActiveRecord#touchメソッドのドキュメントを参照してください。ただし、このStackOverflowの回答に記載されているように、親モデルにもサブスクライバーを追加する必要があります:Elasticsearch、Tire、およびネストされたクエリ/ActiveRecordとの関連付け

もちろん、手動で処理したり、オブザーバーを介して更新をトリガーしたり、バックグラウンド処理/メッセージングを使用したりすることもできます。

于 2012-07-25T11:01:49.823 に答える