zoukankan      html  css  js  c++  java
  • Sphinx 2.2.6 window下安装全过程 未完 持续标记~~~~

    由于在win8.1下安装 选的这个版本

    Win64 binaries w/MySQL+PgSQL+libstemmer+id64 support 2.2.6-release 7.3M

    下载页面

    http://sphinxsearch.com/downloads/release/

    1.编辑配置文件

    下载完 解压 到其中一个目录下

    首先配置sphinx 配置文件 解压后sphinx目录下有个sphinx.conf.in 复制到bin目录下 并改名 sphinx.conf

    配置如下 需要改的几个参数  稍微整理下 在发出

    2.安装步骤

    2.1 安装服务 启动守护进程
    D:wwwSphinxin>searchd --install --config D:wwwSphinxinsphinx.conf --servicename Sphinx
    Sphinx 2.2.6-id64-release (r4843)
    Copyright (c) 2001-2014, Andrew Aksyonoff
    Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

    Installing service...
    Service 'Sphinx' installed successfully.

    2.2 建立索引

    D:wwwSphinxin>indexer.exe --all
    Sphinx 2.2.6-id64-release (r4843)
    Copyright (c) 2001-2014, Andrew Aksyonoff
    Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

    using config file './sphinx.conf'...
    indexing index 'test1'...
    collected 3 docs, 0.0 MB
    sorted 0.0 Mhits, 100.0% done
    total 3 docs, 173 bytes
    total 0.161 sec, 1073 bytes/sec, 18.61 docs/sec
    indexing index 'test1stemmed'...
    collected 3 docs, 0.0 MB
    sorted 0.0 Mhits, 100.0% done
    total 3 docs, 173 bytes
    total 0.061 sec, 2824 bytes/sec, 48.98 docs/sec
    skipping non-plain index 'rt'...
    total 6 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
    total 24 writes, 0.001 sec, 0.1 kb/call avg, 0.0 msec/call avg


    2.3 开启服务

    D:wwwSphinxin>net start Sphinx
    Sphinx 服务正在启动 .
    Sphinx 服务已经启动成功。

    20160828停止Sphinx服务  net stop Sphinx 

    C:WindowsSystem32cmd.exe 右键管理员权限执行  


    PS:按照顺序才是正确的

    3.测试搜索

     

    用的官方API事例调用的 不过有些问题 我把现在改的先发上来参考  还有些没弄明白

     1 <?php
     2 require ( "sphinxapi.php" );
     3 $cl = new SphinxClient ();
     4 $q = "模型";
     5 $sql = "";
     6 $mode = SPH_MATCH_ALL;
     7 $host = "127.0.0.1";
     8 $port = 9312;
     9 $index = "*";
    10 $groupby = "";
    11 $groupsort = "@group desc";
    12 $filter = "id";
    13 $filtervals = array();
    14 $distinct = "";
    15 $sortby = "";
    16 $sortexpr = "";
    17 $limit = 20;
    18 $ranker = SPH_RANK_PROXIMITY_BM25;
    19 $select = "";
    20 
    21 $cl->SetServer ( $host, $port );
    22 $cl->SetConnectTimeout ( 1 );
    23 
    24 $cl->SetArrayResult ( true );
    25 
    26 $cl->SetRankingMode ( $ranker );
    27 $res = $cl->Query ( $q, $index );
    28 var_dump($res);
    29 
    30 if ( $res===false )
    31 {
    32     print "Query failed: " . $cl->GetLastError() . ".
    ";
    33 
    34 } else
    35 {
    36 if ( is_array($res["matches"]) )
    37     {
    38         $n = 1;
    39         print "Matches:
    ";
    40 
    41 
    42         foreach ( $res["matches"] as $docinfo )
    43         {
    44             print "$n. id=$docinfo[id], weight=$docinfo[weight]";
    45             print "
    ";
    46 
    47             foreach ( $res["attrs"] as $attrname => $attrtype )
    48             {
    49                
    50                 $value = $docinfo["attrs"][$attrname];
    51              
    52                 if ( $attrtype==SPH_ATTR_MULTI || $attrtype==SPH_ATTR_MULTI64 )
    53                 {
    54                    
    55                     $value = "(" . join ( ",", $value ) .")";
    56 
    57                 } else
    58                 {
    59                     if ( $attrtype==SPH_ATTR_TIMESTAMP )
    60                         $value = date ( "Y-m-d H:i:s", $value );
    61 
    62 
    63                 }
    64                 print ", $attrname=$value";
    65             }
    66             print "
    ";
    67             $n++;
    68         }
    69     }
    70 
    71 
    72 }
    73 ?>

    搜索得到的结果是这样的

    array(10) {
      ["error"]=>
      string(0) ""
      ["warning"]=>
      string(0) ""
      ["status"]=>
      int(0)
      ["fields"]=>
      array(8) {
        [0]=>
        string(8) "pictitle"
        [1]=>
        string(10) "picsubhead"
        [2]=>
        string(11) "piccategroy"
        [3]=>
        string(6) "pictag"
        [4]=>
        string(8) "picalbum"
        [5]=>
        string(9) "picauthor"
        [6]=>
        string(14) "picdescription"
        [7]=>
        string(8) "picmusic"
      }
      ["attrs"]=>
      array(7) {
        ["pictitle"]=>
        int(7)
        ["picposttime"]=>
        int(2)
        ["picsubhead"]=>
        int(7)
        ["piccategroy"]=>
        int(7)
        ["pictag"]=>
        int(7)
        ["picdescription"]=>
        int(7)
        ["picmusic"]=>
        int(7)
      }
      ["matches"]=>
      array(1) {
        [0]=>
        array(3) {
          ["id"]=>
          int(11)
          ["weight"]=>
          string(4) "2680"
          ["attrs"]=>
          array(7) {
            ["pictitle"]=>
            string(7) "test111"
            ["picposttime"]=>
            string(10) "1417853738"
            ["picsubhead"]=>
            string(8) "fubiaoti"
            ["piccategroy"]=>
            string(6) "模型"
            ["pictag"]=>
            string(8) "zidingyi"
            ["picdescription"]=>
            string(7) "picture"
            ["picmusic"]=>
            string(20) "http://www.baidu.com"
          }
        }
      }
      ["total"]=>
      string(1) "1"
      ["total_found"]=>
      string(1) "1"
      ["time"]=>
      string(5) "0.000"
      ["words"]=>
      array(2) {
        ["模"]=>
        array(2) {
          ["docs"]=>
          string(1) "2"
          ["hits"]=>
          string(1) "2"
        }
        ["型"]=>
        array(2) {
          ["docs"]=>
          string(1) "2"
          ["hits"]=>
          string(1) "2"
        }
      }
    }
    Matches:
    1. id=11, weight=2680
    , pictitle=test111, picposttime=2014-12-06 16:15:38, picsubhead=fubiaoti, piccategroy=模型, pictag=zidingyi, picdescription=picture, picmusic=http://www.baidu.com

    中文词典这些属性设置已经移除charset_dictpath 剩下的 等我研究好了 继续发布

     在版本升级中 重点的东西提下

    在2.2.1-beta版本下

    官方推荐使用 SphinxQL  

     SphinxAPI and Sphinx SE以后将会被移除

    在 2.2.2-beta版本中

    移除了CLI search 以前版本的 search 命名不可用 bin目录下也没有search.exe

    反对使用SetMatchMode() API

    移除了charset_type and mssql_unicod设置 只支持UTF-8编码

     PS: 2.2.6 默认开始了

    listen        = 9306:mysql41 启用了SphinxQL 并且ID默认都是64位
  • 相关阅读:
    [BZOJ 2186][Sdoi2008]沙拉公主的困惑(欧拉函数)
    [BZOJ1271][WC2008]秦腾与教学评估(巧妙的二分)
    [BZOJ2879][Noi2012]美食节(最小费用最大流动态加边)
    [BZOJ1070][SCOI2007]修车(最小费用最大流)
    [BZOJ1211][HNOI2004]树的计数(Prufer序列)
    [BZOJ1406][AHOI2007]密码箱(数论)
    1、体验
    sublime 安装插件
    <a>标签中的href="javascript:;"就是去掉a标签的默认行为
    html 中的media属性
  • 原文地址:https://www.cnblogs.com/xxx91hx/p/4155488.html
Copyright © 2011-2022 走看看