Reputation: 55263
I just installed the Sunspot gem
This is my setup:
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
.
.
.
routes.rb:
resources :posts do
resources :votes
resources :replies
end
The corrects results are returned when I search for the post :title
and :content
. Something weird happens when searching for the replies :content
attribute.
I searched for 3 different terms in 3 different posts: scala, groovy, python
. Only 'scala'
is returning something. I even created another reply in another post with the text 'scala'
, but only the first one is returned as a result.
This is the output (only the first one returns a result):
What can be causing this?
Upvotes: 0
Views: 44
Reputation: 55263
I figured out. I had to do this:
bundle exec rake sunspot:solr:reindex
Upvotes: 1