sphinx分域搜索【不】需要在conf文件中使用sql_field_string

请看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”这种格式就好了。

转载于:https://www.cnblogs.com/miaoz/p/3601631.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值