【发布时间】:2012-10-16 19:00:43
【问题描述】:
多种类型的太阳黑子搜索与单一类型的优缺点是什么?首选的方式是什么?
我查看了很多文档,但似乎找不到答案。
- https://github.com/sunspot/sunspot
- https://github.com/sunspot/sunspot/wiki
- http://sunspot.github.com/sunspot/rails/docs/index.html
- http://sunspot.github.com/sunspot/docs/Sunspot.html#search-class_method
多类型搜索示例:
Sunspot.search(Post, Comment) do
with :blog_id, 1
fulltext 'hello' do
fields(:comment_body)
end
end
关联到另一个模型/类型的单一类型搜索示例:
class Post < ActiveRecord::Base
searchable do
text :comments do
comments.map { |comment| comment.body }
end
end
Post.search do
fulltext 'hello' do
fields(:comments)
end
end
似乎我可以使用任何一种方法(多种类型或单一类型)获得相同的结果。
【问题讨论】:
标签: ruby-on-rails solr sunspot sunspot-rails