跨多个表的MySQL全文搜索 [英] MySQL full text search across multiple tables

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

问题描述

我有一系列包含要全文搜索的数据的表。我已经试过将表与 UNION 结合,但是结果会丢失其全文索引,因此无法进行全文搜索。我不认为将数据放入临时表是一种方法。有没有办法可以全文检索这些表格?

更新:
我的全文查询是

  SELECT ID,标题,描述,作者,MATCH(标题,标签,正文)反对(搜索条款)AS相关性
FROM [表格组合(b)b
WHERE MATCH(标题,标签,正文) >解决方案

MySQL无法在多个表中创建全文(或任何)索引。因此,使用单一索引是不可能的。



或者,您可以:


  1. 在每个表上使用索引,并根据需要使用联合/联合来检索符合要求的行。 创建一个聚合表来应用索引。

  2. 使用诸如lucene或solr之类的工具来提供搜索索引。
  3. (如果您打算进行任何比例缩放,这可能是最佳选择)



I have a series of tables that contain data I want to full text search. I've tried combining the tables with UNION, but the result loses its fulltext index so can't be fulltext searched. I don't think that putting the data into a temp table is the way to go. Is there someway that I can fulltext search these tables efficiently? Thanks in advance!

UPDATE: my query for fulltext was

SELECT ID, Title, Description, Author, MATCH (Title,Tags,Body) AGAINST ("search terms") AS Relevance 
FROM [combination of tables goes here] 
WHERE MATCH (Title,Tags,Body) AGAINST ("search terms")

解决方案

MySQL can't make a fulltext (or any) index accross multiple tables. So using a single index is out.

As an alternative, you could either:

  1. Use an index on each table, and a join/union as appropriate to retrieve the rows that match your requirements.

  2. Create an aggregate table to apply the index to.

  3. Use a tool such as lucene or solr to provide your search index. (If you are going for any sort of scale, this is likely the best option)

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

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