0

Sunspot gemをインストールしました

これは私のセットアップです:

post.rb:

class Post < ActiveRecord::Base
  include ActionView::Helpers

  attr_accessible :title, :content, :category_id, :tag_list

  has_many :replies, dependent: :destroy


  searchable do
    text :title, boost: 5
    text :content
    text :replies do
      replies.map { |reply| reply.content }
    end
  end
  .
  .
  .

posts_controller.rb:

class PostsController < ApplicationController

  def index
    if signed_in?
      @search = Post.search do
        fulltext params[:search]
      end
      #@post = current_user.posts.build
      #@feed_items = current_user.feed.results.paginate(page: params[:page])
      @feed_items = @search.results
    end
    .
    .
    .

ルート.rb:

 resources :posts do
    resources :votes
    resources :replies
  end

投稿:titleとを検索すると、正しい結果が返され:contentます。返信:content属性を検索すると、奇妙なことが起こります。

3 つの異なる投稿で 3 つの異なる用語を検索しました: scala, groovy, python'scala'何かを返すだけです。別の投稿で別の返信をテキストで作成しました'scala'が、結果として返されるのは最初の返信のみです。

これは出力です (最初のものだけが結果を返します):

ここに画像の説明を入力

ここに画像の説明を入力

ここに画像の説明を入力

何が原因でしょうか?

4

1 に答える 1

1

わかった。私はこれをしなければなりませんでした:

bundle exec rake sunspot:solr:reindex
于 2012-11-29T23:23:40.553 に答える