mysql - Sphinxql - How to use query having order by while using Sphinxql in PHP without using sphinxapi.php -
i have been using mysql fts , switched sphinx testing purpose.
installed sphinx on 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 3306 sql_query = \ select content.record_num, \ content.title, \ content.category, \ content.upload_date, \ content.comments_count, \ content.verified, \ content.uploader, \ content.size \ content 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 }
i using php connect sphinxql , run queries, .like this
$sphinxql = @mysqli_connect($sphinxql_host.':'.$sphinxql_port,'',''); $sphinxql_query = "select id $sphinx_index match('".mysqli_real_escape_string($prod1,$q)."') limit $from,$max_results";
simple queries working fine, i.e. queries without order condition. when tried run sql queries having order , sphinx throwing errors .
i.e. query , errors.
select id $sphinx_index match('".mysqli_real_escape_string($prod1,$q)."') order title desc limit $from,$max_results index content_index1: sort-by attribute 'title' not found
another try, replaced field name @field name
select id $sphinx_index match('".mysqli_real_escape_string($prod1,$q)."') order @title desc limit $from,$max_results sphinxql: syntax error, unexpected uservar, expecting ident (or 55 other tokens) near '@title desc limit 0,25'
table has order fields title, category , upload_date , size , verified
so how can use order in sphinxql query
update 1
i have managed run queries "not having order by" , queries having "order by" not working properly,doesnt gives error, gives result sets, if change direction of sort attribute , results sets doesnt changes.
updated fields , attributes as.
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
have tried using column sql_attr_string?
http://sphinxsearch.com/docs/current.html#conf-sql-attr-string
you need @ least version 2.0.1 use order clause on such attribute:
starting 2.0.1-beta string attributes can used sorting , grouping(order by, group by, within group order by).
Comments
Post a Comment