[Rails] mangling search terms
I've been working on a pet project and have just started implementing
full-text searching with acts_as_xapian. It's working pretty well but I'm
having trouble getting some of the bells and whistles to work.
First is the spelling correction. If it feels that there are incorrectly
spelt words, it provides an array of the correct spellings, but without
reference to which words it is correcting.
So if I enter the search term "the cat adn the dog", it will give an array
["and"] which is useless in a gsub because it can't tell what it should be
replacing. I want to be able to say "did you mean 'the cat *and* the dog'?"
but I can't work out how to manipulate the string.
The second puzzle is regarding highlighting the search terms. When you
follow a link to one of the results, it appends the search term to the query
and uses TextHelper::highlighter to mark those words. The problem is that it
is expecting an array, not a string. So I split the string by spaces, but
what about parts of the query that were enclosed in quotes?
I have found it impossible to mangle a complex query such as:
"null pointer" undefined "static char array"
So it can be passed a query parameter and then decoded again for the
highlighter. I've tried all sorts of regexp, splits and joins but it's just
given me a headache.
I know people have done this before so I'm hoping someone can give me some
pointers. Let me know if I can provide any more information to explain
myself better.
Many thanks
Matt
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home