post.rb
...
searchable do
text :title, :description
string :category
time :created_at
integer :post_id
end
...
post_controller.rb
@search = Post.search do
fulltext params[:q]
with(:created_at).less_than Time.zone.now
end
The above code works correctly, but when I try to scope by post_id or category, I get no results.
So, something like
with(:category).equal_to("category_name")
or
with :post_id, 1
Shows no results, and thus does not work correctly. Any ideas on how to debug sunspot solr? I've been to :8982/solr/admin and checked the development logs, but I can't figure out what would be wrong.
You have added search fields but have you reindexed your data? Try calling in console:
RAILS_ENV=yours_env rake sunspot:solr:reindex
AFAIK this is proper behaviour of solr with added new fields but without reindexing (fields are empty so there are no results but also no 'loud' error).