我在Rails应用程序中有以下类:
class Post
include Mongoid::Document
include Sunspot::Mongoid
belongs_to :user
searchable do
text :name
string :user_id
end
end
class Post::Image < Post
searchable do
text :location
time :taken_at
end
end
class Post::Link < Post
searchable do
text :href
end
end
据我所知,调用以下内容应该可行。
Post.search do
fulltext('something')
with(:user_id, user.id)
end
但事实并非如此。它返回一个空结果。调用Post::Link.search
也不起作用:
# => Sunspot::UnrecognizedFieldError: No field configured for Post::Link with name 'user_id'
有什么建议吗?