MySQL全文搜索的替代方案

时间:2022-09-19 19:11:04

I read that MySQL fulltext search can cause table locking. It means people can't insert or update the table when it's being searched on.

我读到MySQL全文搜索会导致表锁定。这意味着人们在搜索时无法插入或更新表格。

I read that there are many search servers (Lucence and Sphinx) can do it without table locking and even faster. It requires many configuration and hard to implement.

我读到有很多搜索服务器(Lucence和Sphinx)可以在没有表锁定的情况下完成它甚至更快。它需要很多配置并且难以实现。

Is there any other way to use fulltext or some searching like that without using search service? I don't want to configure one more server other than MySQL.

有没有其他方法可以使用全文或一些不使用搜索服务的搜索?我不想再配置MySQL以外的其他服务器。

3 个解决方案

#1


2  

Create an extra table which will be used only to perform FULLTEXT searches. In your code you have to ensure that all data and actions (create, update, delete) are properly replicated to this table. This solution is also handy if your data tables are running e.g. InnoDB engine.

创建一个额外的表,仅用于执行FULLTEXT搜索。在您的代码中,您必须确保将所有数据和操作(创建,更新,删除)正确复制到此表。如果您的数据表正在运行,此解决方案也很方便,例如InnoDB引擎。

#2


1  

Apache Lucene doesn't need many configuration and isn't hard to implement. Moreover, it's one of the most popular fulltext search engine, and allows the users to do very precise queries, like "to be or not to be", j?hn d?e, func*, etc.

Apache Lucene不需要很多配置,也不难实现。此外,它是最受欢迎的全文搜索引擎之一,并允许用户进行非常精确的查询,如“成为或不成为”,j?hn d?e,func *等。

I already did some database indexing with Lucene, so if you could be a bit more precise about which fields of which tables you wanna index, I can give you pieces of code which should do the trick.

我已经使用Lucene进行了一些数据库索引,所以如果你能更精确地指出你想要索引哪些表的哪些字段,我可以给你一些应该做的诀窍代码。

#3


0  

I vote for Sphinxsearch anyway. It has one of APIs close to Mysql, easy to install and configure. Not so universal as Apache Lucene, but jet quick and very helpful in my projects.

无论如何,我投票支持Sphinxsearch。它有一个接近Mysql的API,易于安装和配置。不像Apache Lucene那么普遍,但在我的项目中快速且非常有用。

#1


2  

Create an extra table which will be used only to perform FULLTEXT searches. In your code you have to ensure that all data and actions (create, update, delete) are properly replicated to this table. This solution is also handy if your data tables are running e.g. InnoDB engine.

创建一个额外的表,仅用于执行FULLTEXT搜索。在您的代码中,您必须确保将所有数据和操作(创建,更新,删除)正确复制到此表。如果您的数据表正在运行,此解决方案也很方便,例如InnoDB引擎。

#2


1  

Apache Lucene doesn't need many configuration and isn't hard to implement. Moreover, it's one of the most popular fulltext search engine, and allows the users to do very precise queries, like "to be or not to be", j?hn d?e, func*, etc.

Apache Lucene不需要很多配置,也不难实现。此外,它是最受欢迎的全文搜索引擎之一,并允许用户进行非常精确的查询,如“成为或不成为”,j?hn d?e,func *等。

I already did some database indexing with Lucene, so if you could be a bit more precise about which fields of which tables you wanna index, I can give you pieces of code which should do the trick.

我已经使用Lucene进行了一些数据库索引,所以如果你能更精确地指出你想要索引哪些表的哪些字段,我可以给你一些应该做的诀窍代码。

#3


0  

I vote for Sphinxsearch anyway. It has one of APIs close to Mysql, easy to install and configure. Not so universal as Apache Lucene, but jet quick and very helpful in my projects.

无论如何,我投票支持Sphinxsearch。它有一个接近Mysql的API,易于安装和配置。不像Apache Lucene那么普遍,但在我的项目中快速且非常有用。