I've given this some thought, and I'm not sure of the best way to achieve it at the moment without intersection support. I had been kind of procrastinating doing something like this until there was some demand - and you are the first person to request it. ;-)
A very basic (and not very efficient) implementation would be to iterate over the terms storing the results in an array and using ruby's intersection operator (&) to find the set of matches for all terms.
I'll noodle on this a bit - and if you have other ideas, please feel free to email or post them.
Thanks
Lance
On 3/10/06, Piers Young
<[EMAIL PROTECTED]> wrote:
Hi
I've got the Indexed Search engine up and running, but it currently
returns results for all items matching any of the terms in the search
field.
I was wondering if anyone knew whether there's a switch I'm missing so
that it returns all items matching every terms in the search field?
I've been playing around with the IndexableRecord.rb code (l.100 on):
# Search the index. Phrase is expected to be a string of
# one or more words. The phrase will be tokenized with Tokenizer,
# stop words will be removed, and each term will be stemmed.
# This will allow a search for "Running" to return records with
# the terms "run", "ran" and "runner"
def IndexableRecord.search(phrase)
results = []
terms = Tokenizer.tokenize(phrase).collect do |t| t.stem end
terms.empty? ? [] : Context.find(:all, :include => :terms,
:conditions => ["term IN (?)", terms])
end
but am getting in a complete spin trying to sort out the conditions for
a boolean and, partly because MySQL doesn't seem to support intersects.
Any help/suggestions/ideas would be hugely appreciated!
Piers
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
engine-users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org
--
Lance Ball
http://lance.langwell-ball.com
_______________________________________________ engine-users mailing list [email protected] http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org
