在Book模型中,您需要
search_data为索引建立一个块。
def search_data attributes.merge( author_name: author(&:name) publisher_name: publisher(&:name) subjects_name: subjects.map(&:name) )end
这会将关联添加到您的索引中。
您将
.map方法用于
has_many关联。

在Book模型中,您需要
search_data为索引建立一个块。
def search_data attributes.merge( author_name: author(&:name) publisher_name: publisher(&:name) subjects_name: subjects.map(&:name) )end
这会将关联添加到您的索引中。
您将
.map方法用于
has_many关联。