任何第三方搜索引擎(全文搜索等)都可以与 InnoDB 表一起正常工作吗?
我知道,InnoDB 表还不支持全文搜索。所以我想到使用第三方搜索引擎,如 solr、xapian 或 whoosh。这些第三方工具对 InnoDB 表的处理是否与对 MyIsam 表的处理一样好?我需要找到例如拼写建议和类似的字符串......
I know, that InnoDB tables do not support fulltext searches, yet. So I thought of using a third party search engine like solr, xapian or whoosh. Do those third party tools work equivalently fine with InnoDB tables as they work with MyIsam tables? I need to find e.g. spelling suggestions, and similar strings...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Solr/Lucene 对数据库数据进行全文搜索。由于我的 MySQL 数据库对于快速全文搜索来说太大了,我决定将 mysql 和 Solr/lucene 结合起来。
重要的是要知道,Solr/Lucene 不是 MySQL 插件。因此,您将无法使用典型的 MySQL SQL 语句来搜索全文索引。由应用程序发起的全文搜索应首先将请求发送到第 3 方全文索引 (Solr),后者返回相关文档的主键。第二步是使用带有来自 Solr 结果集的相应主键的 where 子句对 MySQL innoDB 运行 SQL 语句。
该解决方案在我的案例中效果非常好,并且比典型的 MySQL Myisam 全文搜索快得多(更好)。
作为替代方案,您不仅可以在 solr 中索引数据。您还可以另外将数据存储在 solr 中。在这种情况下,solr 能够返回全文。因此,您不需要从数据库获取数据,如上面的示例所示。
绝对地。 Solr 有一个 DataImportHandler。然后,您定义一条 SQL 语句来获取您想要在 solr 中索引的数据,例如:
select * from MyTable;
但请记住:目前(据我所知)没有可用的 MySQL solr 插件。 Solr和MySQL的配合应该由应用程序来处理。
You could use Solr/Lucene to do the fulltext-search over your DB data. Since my MySQL DB is to big for an fast fulltext-search, i decided to combine mysql and Solr/lucene.
It's important to know, that Solr/Lucene is not an MySQL Plugin. So you will not be able to search the fulltext-index by using typical MySQL SQL-Statements. An fulltext-search, initiated by the application, should be first send the request to the 3rd party fulltext-index (Solr), which returns the primary keys of the related documents. Second step is to run an SQL statement against your MySQL innoDB with an where clause with the corresponding primary keys from the Solr result set.
That solution works in my case very well and much, much faster (and better) than an typical MySQL Myisam fulltext-search.
As an alternative you could not only index the data in solr. You also could store the data in solr additionally. In that case, solr is able to return the full text. So you don't need get the data form the database, as in the example above.
Absolutely. Solr has an DataImportHandler. Ther you define an SQL statement in order to get the data you like to index in solr, like:
select * from MyTable;
But keep in mind: right now (as far as I know) ther is no MySQL solr plugin available. The cooperation of Solr and MySQL should be handled by the application.
第三方全文搜索引擎通常复制 MySQL 查询返回的数据,并使用它来填充其搜索索引。 MyISAM 和 InnoDB 数据源在这方面没有区别。
我做了一个演讲MySQL 中的实用全文搜索 几年前。你可能会觉得很有趣。
Third-party fulltext search engines typically copy data returned by a MySQL query, and use it to populate their search index. There's no difference between MyISAM and InnoDB data sources in this respect.
I gave a presentation Practical Full-Text Search in MySQL a few years ago. You might find it interesting.
Sphinx
支持自己的索引,只需通过发出查询及时从MySQL
获取数据。它甚至不知道底层的表结构,只要查询运行并返回结果,
Sphinx
就可以了。其他第三方引擎的工作方式类似。
Sphinx
supports its own index and just takes data fromMySQL
on a timely basis by issuing a query.It is not even aware of the underlying table structure and as long as the query runs and returns the results, it's OK for
Sphinx
.Other third party engines work in a similar way.