The documentation for more_like_this
演示瞭如何使用它來獲得更多的同類型的內容基於一個條件類似的:是否可以在不同的數據類型中使用more_like_this?
class Post < ActiveRecord::Base
searchable do
# The :more_like_this option must be set to true
text :body, :more_like_this => true
end
end
post = Post.first
results = Sunspot.more_like_this(post) do
fields :body
minimum_term_frequency 5
end
我不知道是否有可能返回相關的項目是不同的數據類型。例如,與Articles
相關/相似的Videos
。
我想這取決於是否more_like_this
沿着「更Articles
類似於此Article
基於一套標準」或的流水線作業,如果它沿與此類似Article
的「更多的東西線運行根據一組標準「...
我的用例是這樣的,如果我顯示的是Article
,我想在頁面上顯示相關內容 - 可能是其他的Articles
,Videos
同一類別,或Events
等相關主題等。
謝謝!不幸的是,我遇到了[這個bug](https://github.com/sunspot/sunspot/issues/148),它禁止通過'more_like_this'傳遞多個對象 - 所以,在你的例子中'頁面'...或'Sunspot.more_like_this(post,Post,Page,Video,Event)'作爲另一個例子失敗,出現'undefined method'more_like_this_fields''錯誤。 –