1

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'

助言がありますか?

4

0 に答える 0