在我的應用程序正在使用MySQL查詢的正確方法:獅身人面像查詢 - 查詢
SELECT DISTINCT * FROM forum_topic \
LEFT JOIN forum_post ON forum_post.id_topic = forum_topic.Id \
WHERE MATCH (forum_post.content) AGAINST ('searching text') \
AND !MATCH (forum_topic.topic_name) AGAINST ('searching text') \
GROUP BY forum_topic.Id
,但現在我想遷移到獅身人面像。我在DB中創建了配置文件和表sph_counter。現在我的配置看起來像這樣:
source main
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = sphinx
sql_port = 3306 # optional, default is 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX(Id) FROM forum_post
sql_query = SELECT * FROM forum_topic LEFT JOIN forum_post ON forum_post.id_topic = forum_topic.Id \
WHERE forum_post.Id<=(SELECT max_doc_id FROM sph_counter WHERE counter_id=1)
AND MATCH (forum_post.content) AGAINST ('searching text') \
AND !MATCH (forum_topic.topic_name) AGAINST ('searching text')
GROUP BY(forum_topic.Id)
sql_attr_uint = id_topic
}
source delta : main
{
sql_query_pre = SET NAMES utf8
sql_query = SELECT * FROM forum_topic LEFT JOIN forum_post ON forum_post.id_topic = forum_topic.Id \
WHERE forum_post.Id<=(SELECT max_doc_id FROM sph_counter WHERE counter_id=1)
AND MATCH (forum_post.content) AGAINST ('searching text') \
AND !MATCH (forum_topic.topic_name) AGAINST ('searching text')
GROUP BY(forum_topic.Id)
}
index main
{
source = main
path = /var/data/main_sphinx
charset_type = utf-8
}
index delta : main
{
source = delta
path = /var/data/delta_sphinx
charset_type = utf-8
}
這是我用斯芬克斯搜索的正確方法嗎?或者我從PHP腳本執行此操作?