sphinx中过滤的简单介绍

1.过滤字符串为空的一些记录的话,可以在sql_query中直接加上where来限制,如:

sql_query  = \
  SELECT a.location_id as id,a.location_id,a.location_name as `location_name`,a.location_name as `name`,a.location_bname,a.attach_id,a.showstatus,CRC32(a.showstatus) as crc32_showstatus,a.is_del,a.status,b.area_name as city_name FROM `ts_rdd_location` a LEFT JOIN `ts_rdd_area` b ON a.city_id = b.area_id where a.attach_id is not null

 

2.过滤字段为某个具体值的话,可以用setFliter来过滤,如果showstatus要为'Y'的,可以CRC32(a.showstatus) as crc32_showstatus,

然后:

sql_attr_uint        = crc32_showstatus

php中调用的时候,

'crc32_showstatus' => sprintf('%u', crc32('Y'))

if (isset($filterArr['crc32_showstatus'])) {
   $spx->SetFilter('crc32_showstatus', array($filterArr['crc32_showstatus']));
  }

来控制。

你可能感兴趣的:(php)