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''错误。 –