针对列值的MySQL全文搜索? [英] MySQL Fulltext search against column value?

查看:94
本文介绍了针对列值的MySQL全文搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对另一个表中的列中的大量值进行全文搜索。由于MATCH()需要AGAINST()部分中的值,所以直接:SELECT a.id FROM a,b WHERE MATCH(b.content)AGAINST(a.name)失败并显示AGAINST的参数不正确。

现在,我知道我可以编写一个脚本来查询名称列表,然后搜索它们,但我宁愿制定一个更复杂的查询可以一次处理它。它不需要很快。



想法?



谢谢

解决方案

不幸的是, http://dev.mysql.com/doc/refman/5.6/en/fulltext-search.html 说:


搜索字符串必须是查询评估期间不变的字符串值。例如,这排除了表列,因为每列都可能有所不同。


看起来您必须搜索如果你使用MySQL的 FULLTEXT 索引作为你的搜索解决方案,那么这些模式是一次一个。



考虑允许搜索许多模式,例如您描述的是倒排索引。虽然这不像真正的全文搜索技术那样灵活或可扩展。



查看我的演示文稿 http://www.slideshare.net/billkarwin/practical-full-text-search-with-my-sql


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

解决方案

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

The search string must be a string value that is constant during query evaluation. This rules out, for example, a table column because that can differ for each row.

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

这篇关于针对列值的MySQL全文搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆