0

I have MySQL and Sphinx installed and working properly on a LNMP server. Now I'd like to integrate a Sphinx sub-query into an existing MySQL query.

Example:

SELECT * FROM mysql_table
JOIN (SELECT id FROM sphinx_index MATCH ('keyword')) AS match_table
ON match_table.id = mysql_table.id

Is this possible? If not, should I do the Sphinx separately and then use WHERE IN in the MySQL query, or will this kill the extra efficiency I'm getting from Sphinx?

4

2 回答 2

1

使用 SphinxSE http://sphinxsearch.com/docs/current.html#sphinxse-overview

那么将是

SELECT * FROM mysql_table
JOIN (SELECT id FROM sphinx_index WHERE query='keyword') AS match_table
ON match_table.id = mysql_table.id

虽然

SELECT * FROM sphinx_index INNER JOIN mysql_table USING (id) WHERE query='keyword'

更短更简洁。更好地保持结果的顺序。

其中 'sphinx_index' 是一个 SphinxSE 表,它指向底层的 sphinx 索引。

于 2012-10-01T12:54:56.647 回答
0

看来我在另一个 SO 问题上找到了答案:

将 Sphinx 集成到 MySQL

通过阅读本文,Sphinx 和 MySQL 似乎不像我希望的那样集成。它们需要在单独的连接上使用,因此您不能组合查询。那好吧...

于 2012-10-01T00:51:03.113 回答