def get_results
if request.xhr?
if params[‘search_text’].strip.length > 0
terms = params[‘search_text’].split.collect do |word|
“%#{word.downcase}%”
end
@users = User.find(
:all,
:conditions => [
( ["(LOWER(email) LIKE?)"] * terms.size ).join(" AND "),
* terms.flatten
]
)
end
render :partial => “search”
else
redirect_to_index
end
end
I’m not sure how to make the algorithm more accurate.
If I have this in my database:
jolt
two
tww
and I search for: ‘t’
It brings both of them up because they have have a t in them.
How can I make sure it’s search for the exact letters in sequence,
i.e.
search: ‘t’
=> two
=> tww
search: ‘two’
=> two
Thanks!
results: two