Question

Unless I'm high, I'm following the docs exactly but the scoping is still not working. I'm not getting any errors, just an empty array in the results when I do the following:

search = Product.search do
  with(:website_id, 2)
end

@results = search.results

The response I get from the console is this:

=> <Sunspot::Search:{:fq=>["type:Product", "website_id_i:2"], :start=>0, :rows=>30, :q=>"*:*"}>

Here's what the code on my Product model looks like:

searchable do
  text :name
  integer :website_id
end

when I do the same search using "without", I actually get the record with website_id of 2. I just dont understand why the scoping isn't working on the 'with' method.

I have updated to the latest version of both the sunspot_rails & sunspot_solr gems.

No correct solution

OTHER TIPS

Figured it out. Had to reindex solr in order to reflect the changes made on my model.

bundle exec rake sunspot:solr:stop
bundle exec rake sunspot:solr:start
bundle exec rake sunspot:solr:reindex

Then, restart your rails server, restart your console, and all should be happy again in happy land.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top