我一直使用mysql FTS,但最近切換到sphinx進行測試。Sphinxql - 如何在不使用sphinxapi.php的情況下使用在PHP中使用Sphinxql的順序的查詢
CentOS上安裝了獅身人面像7
Linux production 3.10.0-123.8.1.el7.x86_64 #1 GNU/Linux
的sphinx.conf
source content_src1
{
type = mysql
sql_host = localhost
sql_user =
sql_pass =
sql_db = t_prod2
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT content.record_num, \
content.title, \
content.category, \
content.upload_date, \
content.comments_count, \
content.verified, \
content.uploader, \
content.size \
FROM content WHERE enabled = 1
sql_attr_uint = record_num
sql_attr_string = title
}
index content_index1
{
source = content_src1
path = /var/lib/sphinx/content_index1
morphology = stem_en
min_word_len = 1
min_prefix_len = 0
min_infix_len = 1
docinfo = extern
}
我使用PHP來連接sphinxql和運行查詢,該。像
$sphinxql = @mysqli_connect($sphinxql_host.':'.$sphinxql_port,'','');
$sphinxql_query = "SELECT id FROM $sphinx_index WHERE MATCH('".mysqli_real_escape_string($prod1,$q)."') LIMIT $from,$max_results";
簡單的查詢是工作正常,即查詢沒有任何條件的順序。 但是當我試圖運行SQL查詢順序時,獅身人面像正在拋出錯誤。
即 查詢及其錯誤。
SELECT id FROM $sphinx_index WHERE MATCH('".mysqli_real_escape_string($prod1,$q)."') ORDER BY title DESC LIMIT $from,$max_results
index content_index1: sort-by attribute 'title' not found
闖闖,我代替字段名與@field名
SELECT id FROM $sphinx_index WHERE MATCH('".mysqli_real_escape_string($prod1,$q)."') ORDER BY @title DESC LIMIT $from,$max_results
sphinxql: syntax error, unexpected USERVAR, expecting IDENT (or 55 other tokens) near '@title DESC LIMIT 0,25'
表來按標題,類別,UPLOAD_DATE,大小字段有訂單,經覈實
憑什麼我用命令在我的sphinxql查詢
更新1
我已經設法運行查詢「沒有排序」,但具有「排序」的查詢不能正常工作,沒有給出錯誤,給出了結果集,但是如果我改變排序方向的屬性,結果集不會變化。
更新的字段和屬性如下所示。
sql_field_string = title
sql_field_string = og_name
sql_field_string = hash
sql_field_string = keywords
sql_attr_timestamp = upload_date_timestamp
sql_attr_uint = category
sql_attr_uint = comments_count
sql_attr_bool = verified
sql_attr_bigint = size
也許需要指定ORDER BY標題COLLATE utf8_general_ci DESC –