zoukankan      html  css  js  c++  java
  • php操作sphinx

    ubuntu下的sphinx安装

    sphinx安装:sudo apt-get install sphinxsearch

    配置sphinx
    进入/etc/sphinx/search
    cp sphinx-min.conf.disc sphinx.conf
    (sphinx-min.conf.disc是模板文件sphinx.conf是配置文件)
    配置文件讲解:
    source src1:主数据源
    index test1 主数据索引
    indexer 索引器大小
    searchd:开启服务配置(端口等)



    建立索引:indexer --all --rotate 可以在不停止sphinx下重新索引


    创建主索引:

        bin/indexer --config etc/sphinx.conf hx_9enjoy --rotate

    创建增量索引:

        bin/indexer --config etc/sphinx.conf delta --rotate

    合并主索引和增量索引:

        bin/indexer --config etc/sphinx.conf --merge hx_9enjoy delta --merge-dst-range deleted 0 0 --rotate

    ---------------------------------------------------------------

    //记住包含sphinxapi类库
    include('sphinxapi.class.php');

    $s = new SphinxClient;
    $s->setServer("localhost", 9312);                //连接sphinx
    $s->setMatchMode(SPH_MATCH_EXTENDED2);           //设置sphinx匹配模式
    $vid=2611673721;
    //$svid=$this->network->shortgz($vid);

    //$s->setLimits(1,10);                            //设置sphinx返回数目
    $s->SetFiltr('gender',array(0));                   //设置sphinx过滤条件 0为男 gender为字段
    $result = $s->query($svid,"users",30);             //在sphinx里通过用户uid查询



    $num=$result["total_found"];                       //sphinx返回条数

    $str=join(',',array_keys($result['matches']));     //取得id去数据库中in

    print_r($result);




    //sphinx中文文档
    //http://www.coreseek.cn/docs/coreseek_4.1-sphinx_2.0.1-beta.html#api-func-setfilter

    //即时索引和索引合并(待续)

  • 相关阅读:
    【BUAA软工】Beta阶段设计与计划
    Visual Lab Online —— 事后分析
    Alpha阶段项目展示
    Visual Lab Online —— Alpha版本发布声明
    【BUAA软工】Alpha阶段测试报告
    Scrum Meeting #10 2020/04/19
    BUAA-OO-第一单元总结
    [软工顶级理解组] 0520第26次会议
    [软工顶级理解组] 0519第25次会议
    [软工顶级理解组] 0517第24次会议
  • 原文地址:https://www.cnblogs.com/xiongwei89/p/2971486.html
Copyright © 2011-2022 走看看