开发者

Sunspot: How does the delta indexing work?

I am investigating Sunspot as a possible indexing solution for our project. There is one thing, I don't find any information about though: How are updates to the data handled. If I have "setup" the class I wish to index, how does the solr server get not开发者_运维知识库ified about changes to the object?

In addition, consider the following scenario:

I have class Artwork which "has_many" Synonym and I would construct my index this way:

Sunspot.setup(Artwork)
  text :synonyms do
    synonyms.map { |s| s.name }
  end
end

Given an artwork "Mona Lisa" with the synonyms "La Gioconda" and "Not so big smile". When I now update the last synonym, would solr be notified and would it rebuild the index for "Mona Lisa"?


If you're using Sunspot::Rails and an ActiveRecord model, there is a lifecycle hook that will automatically update the record's data in Solr whenever the model is saved. However the above looks like you're using pure Sunspot, in which case you'll need to set up your own lifecycle hook, e.g.:

after_save { |artwork| Sunspot.index(artwork) }

You'll also need your own lifecycle logic for any situation in which updating a dependent model needs to update the parent document in Solr (e.g. updates directly to the Synonym models above).


No, there is no such automatic notification exist with Solr. As the synonyms are stored in the txt file, you will have to restart solr server and then reindex. The same case with any solr configuration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜