Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
# Let's say I have the following user.
user = User.create(:company_name => "The cheappo restaurant")
# And the following User finder that works with `starting_with`.
def self.find_all_by_indexed_company_name(term)
Sunspot.search(self) do |q|
q.text_fields { with(:company_name).starting_with(term) }
end.results
end
# Now let's try some queries
User.find_all_by_indexed_company_name("the")
=> user
User.find_all_by_indexed_company_name("the ch")
=> user
# Now if I search for "estaurant"
User.find_all_by_indexed_company_name("estaurant")
=> []
# This is why I say `starting_with` partially works for me,
# I would like to have an indexed search using something like `LIKE`:
User.find(:all, :conditions => ["company_name LIKE ?", "%estaurant%"])
=> user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.