[noob] Help wanted, can't see effective results.

Skip to first unread message


Oct 11, 2015, 7:43:29 PM10/11/15
to Sunspot
Hey everybody!

I'm trying to use to sunspot for the first time and I've been banging against the wall for some reason. Bear with the noob here :)

So here's the deal: I follow the very first steps to make a model searchable. I try to perform a search and, for some reason, I get all records anyway.

  1. A Project model that looks like this:
    • class Project < ActiveRecord::Base
        has_many :tasks

        validates :name, presence: true

        searchable do
          text :name

  2. The following list of name I have for project models (among many others I have):
  • Essential Ruby Libraries
  • Get Started With Ruby on Rails
  • Taking a Feature to Exhaustion
  • Let's Learn Ember
  • Test-Driven Development in Ruby
When I search for 'exhaustion' with: Project.search { fulltext 'exhaustion' }.result,  I get all 37 records I have.

What's wrong with the picture? Am I missing something?


Oct 13, 2015, 10:09:00 AM10/13/15
to Sunspot, josemo...@gmail.com
I don't have a solid answer for why you see them all, but I can suggest a few things to try out.  You could also look at the score returned for each of your hits which may offer you some clue about how much those are matched, or at least show if the other ones resturned have a low score.  Maybe try double checking the solr query by reviewing your rails logs.  You should see a solr query in your logs that will offer some clues about what it is searching and what it is searching on.  Sometimes that helps me figure out if the query I thought I wrote is really the query that gets run.  You could also try double checking that all of your models are indexed correctly, maybe reindexing them.
Reply all
Reply to author
0 new messages