请看sql_field_string的文档说明:
# combined field plus attribute declaration (from a single column) # stores column as an attribute, but also indexes it as a full-text field # # sql_field_string = author
我们不需要attribute属性,不用管。只要在sql_query中选出相应的column就行了,就可以在php中使用extended_query_mode来进行query了,相应的域名就是列的名字。请看如下的conf文件:
sql_query = SELECT bid, review_count, stars, name, full_address, categories FROM busi_info sql_attr_uint = review_count sql_attr_uint = stars
在php中搜索的时候,php文件如下:
<?php ini_set(‘memory_limit‘, ‘-1‘); ini_set(‘max_execution_time‘, ‘100‘); include ‘sphinxapi.php‘; $sc= new SphinxClient(); $sc->setServer(‘localhost‘, 9312); $sc->setRankingMode(SPH_RANK_NONE); $sc->SetLimits(0,73180000,1000000); $sc->SetMatchMode(SPH_MATCH_EXTENDED2); $res = $sc->query(‘@categories Travel‘, ‘idx_busi‘); $ids = array_keys($res[‘matches‘]); print_r($ids); ?>
这样就行啦!只要用“@域名 query”这种格式就好了。