Добрый день.
Имеется Sphinx 2.0.4 с вот такой конфигурацией:
source tickets
{
type = mysql
sql_host = db
sql_user = db_user
sql_pass = db_pass
sql_db = db_name
sql_port = 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = SET CHARACTER SET utf8
sql_query = SELECT id, title, description, image_small, pay, created, slug, type, pay_period_id,currency_id \
city_id FROM ticket
sql_field_string = title
sql_field_string = description
sql_attr_string = slug
sql_attr_string = image_small
sql_attr_timestamp = created
sql_attr_uint = type
sql_attr_uint = pay
sql_attr_uint = user_id
sql_attr_uint = pay_period_id
sql_attr_uint = currency_id
sql_attr_uint = city_id
sql_attr_multi = uint tag_ids from query; SELECT ticket_id, tag_id FROM ticket_tag
}
С помощью расширения yiisoft/yii2-sphinx делаю запрос вот таким образом:
$query = SphinxTicket::find();
$query->where(['type'=>$type]);
if($this->match){
$query->match($this->match);
}
if($this->pay_min) $query->andWhere(['>=','pay',$this->pay_min]);
if($this->pay_max) $query->andWhere(['<=','pay',$this->pay_max]);
В ответ получаю вот такую ошибку:
SQLSTATE[42000]: Syntax error or access violation: 1064 sphinxql: syntax error, unexpected '(', expecting IDENT (or 5 other tokens) near '((`type`=1) AND (`pay` >= '1000')) AND (`pay` <= '100000') LIMIT 2; SHOW META'
The SQL being executed was: SELECT * FROM `tickets_index` WHERE ((`type`=1) AND (`pay` >= '1000')) AND (`pay` <= '100000') LIMIT 2; SHOW META
Каким образом необходимо составлять запрос к Sphinx, чтобы выбирать записи по нескольким полям + match?