tags:

views:

213

answers:

1

I need to do a Fulltext search for a whole bunch of values out of a column in another table. Since MATCH() requires a value in the AGAINST() part, a straightforward: "SELECT a.id FROM a,b WHERE MATCH(b.content) AGAINST(a.name)" fails with "Incorrect arguments to AGAINST".

Now, I know I could write a script to query for a list of names and then search for them, but I'd much rather work out a more complex query that can handle it all at once. It doesn't need to be speedy, either.

Ideas?

thanks

A: 

Unfortunately, http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html says:

The search string must be a literal string, not a variable or a column name.

Looks like you'll have to search for the patterns one at a time if you use MySQL's FULLTEXT index as your search solution.

The only alternative I can think of to allow searching for many patterns like you describe is an Inverted Index. Though this isn't as flexible or scalable as a true full-text search technology.

See my presentation http://www.slideshare.net/billkarwin/practical-full-text-search-with-my-sql

Bill Karwin
Yeah, I've seen that, but http://dev.mysql.com/tech-resources/articles/full-text-revealed.html says ""The argument to AGAINST() must be a constant string." This is nothing to worry about. We just haven't updated the manual yet to show that the AGAINST() argument can be a variable or parameter, if you use MySQL Version 5." I was hoping someone would have some advice using some kind of more complex sql approach (views, procedures, or something).Actually, what I'm up to is basically building an inverted index of terms from table a occurring in table b's text column.
Eric B
That article is from May 2004, but they *still* haven't updated the manual?! That's pathetic!
Bill Karwin
Says something about the importance of fulltext to mysql, i suppose. I've found myself studying Squid lately, but this is a side-aspect to a project, and I really had no intention of systemic changes.
Eric B