I am trying to use Ferret for searching for users based on first and
last name.
In my index, I am adding the first_name, last_name, and a full_name
which is basically “#{first_name} #{last_name}”.
I am searching the index using something like the following query:
INDEX.search_each(%Q/first_name:#{query}* OR last_name:#{query}* OR
full_name:#{query}*/) do |doc, score|
The problem I am having is when I search the index it is tokenizing my
query so that each word is being evaluated independantly. For
example, if I search for ‘John D.’, both ‘John’ and ‘Doe’ will match,
so if someone is named ‘Jane Doe’ it will match and if someone is
named ‘John S.’ it will match.
Is there a way to not tokenize the query that is passed into the
search_each method?
Also, is there a better way to search for the full name by just using
the first_name and last_name keys rather than creating a separate key
for the full name?
Thanks,
Tom