source ccvms_video_main
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass = tddb2012yu
sql_db = tangdou
sql_query_pre = SET NAMES utf8
sql_query_pre = SET SESSION query_cache_type=OFF
sql_query_pre = replace into sph_counter select 1,max(vid) from ccvms_video
sql_query = select vid, uid, title, createtime, status, playstatus, type FROM ccvms_video where vid<=(select max_doc_id from sph_counter where counter_id=1)
sql_ranged_throttle = 0
sql_query_info = SELECT * FROM ccvms_video WHERE vid=$id
sql_attr_timestamp = createtime 设置属性,按字段createtime排序
sql_attr_uint = status
sql_attr_uint = playstatus
sql_attr_uint = type
}
php文件中指定匹配模式:
$sphinx->SetSortMode(SPH_SORT_TIME_SEGMENTS, "createtime","@weight"); 先按字段权重排序,然后按createtime排序
// 按分页取结果
$sphinx->SetLimits(($page-1)*$pageSize, $pageSize); //第一个参数为offset,第二个参数为limit
// 模式
//$sphinx->SetMatchMode(SPH_MATCH_ALL);
//$sphinx->SetMatchMode(SPH_MATCH_ANY);
//$sphinx->SetMatchMode(SPH_MATCH_EXTENDED);
$sphinx->SetFieldWeights(array('title'=>2));
//$sphinx->SetMatchMode(SPH_MATCH_EXTENDED,"@weight");
//$sphinx->SetRankingMode(SPH_MATCH_PROXIMITY);
//$sphinx->SetSortMode('SPH_SORT_EXPR','@weight');
$sphinx->SetFilter ( "status", array ( 0 ) );
$sphinx->SetFilter ( "playstatus", array ( 0 ) );
$sphinx->SetFilter ( "type", array ( 1,4,6,7,10 ) );
本文转自ljl_19880709 51CTO博客,原文链接:http://blog.51cto.com/luojianlong/1345684,如需转载请自行联系原作者