zoukankan      html  css  js  c++  java
  • 全文检索引擎 sphinxcoreseek中文索引

    Sphinx是一个基于SQL的全文检索引擎,可以结合MySQL,PostgreSQL做全文搜索,它可以提供比数据库本身更专业的搜索功能,使得应用程序更容易实现专业化的全文检索。

    Sphinx特别为一些脚本语言设计搜索API接口,如PHP,Python,Perl,Ruby等,同时为MySQL也设计了一个存储引擎插件。

    Sphinx 单一索引最大可包含1亿条记录,在1千万条记录情况下的查询速度为0.x秒(毫秒级)。

    Sphinx创建索引的速度为:创建100万条记录的索引只需 3~4分钟,创建1000万条记录的索引可以在50分钟内完成,而只包含最新10万条记录的增量索引,重建一次只需几十秒。

    Sphinx的主要特性包括:

      高速索引 (在新款CPU上,近10 MB/秒);

      高速搜索 (2-4G的文本量中平均查询速度不到0.1秒);

      高可用性 (单CPU上最大可支持100 GB的文本,100M文档);

      提供良好的相关性排名 支持分布式搜索;

      提供文档摘要生成;

      提供从MySQL内部的插件式存储引擎上搜索 支持布尔,短语, 和近义词查询;

      支持每个文档多个全文检索域(默认最大32个);

      支持每个文档多属性;

      支持断词;

      支持单字节编码与UTF-8编码;

     1 # 下载coreseek:coreseek 3.2.14
     2 $ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
     3 $ tar xzvf coreseek-3.2.14.tar.gz
     4 $ cd coreseek-3.2.14 
     5 
     6 #前提,需提前安装操作系统基础开发库及mysql依赖库以支持mysql数据源和xml数据源
     7 #安装mmseg
     8 $ cd mmseg-3.2.14
     9 $ ./bootstrap    #输出的warning信息可以忽略,如果出现error则需要解决
    10 $ ./configure --prefix=/usr/local/mmseg3
    11 $ make && make install
    12 $ cd ..
    13 
    14 #安装coreseek
    15 $ cd csft-3.2.14 或者 cd csft-4.0.1 或者 cd csft-4.1
    16 $ sh buildconf.sh    #输出的warning信息可以忽略,如果出现error则需要解决
    17 ./configure --prefix=/usr/local/coreseek  --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql
    18 
    19 #./configure --prefix=/coreseek/sphinx/coreseek  --without-unixodbc --with-mmseg --with-mmseg-includes=/coreseek/sphinx/mmseg3/include/mmseg/ --with-mmseg-libs=/coreseek/sphinx/mmseg3/lib/ --with-mysql
    20 ##如果提示mysql问题,可以查看MySQL数据源安装说明
    21 $ make && make install
    22 $ cd ..
    23 
    24 ,测式coreseek
    25 #测试mmseg分词,coreseek搜索(需要预先设置好字符集为zh_CN.UTF-8,确保正确显示中文)
    26 $ cd testpack
    27 $ cat var/test/test.xml    #此时应该正确显示中文
    28 $ /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc var/test/test.xml
    29 $ /usr/local/coreseek/bin/indexer -c etc/csft.conf --all
    30 $ /usr/local/coreseek/bin/search -c etc/csft.conf 网络搜索
    31 cd ../testpack
    32 $  /usr/local/coreseek/bin/indexer -c etc/csft.conf
    33 
    34 #以下为正常情况下的提示信息:
    35     Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    36     Copyright (c) 2007-2010,
    37     Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    38 
    39      using config file 'etc/csft.conf'...
    40     total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
    41     total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
    42 
    43 $  /usr/local/coreseek/bin/search -c etc/csft.conf
    44 #以下为正常测试搜索时的提示信息:(csft-4.0版类似)
    45     Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    46     Copyright (c) 2007-2010,
    47     Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    48 
    49      using config file 'etc/csft.conf'...
    50     index 'xml': query '': returned 3 matches of 3 total in 0.093 sec
    51 
    52     displaying matches:
    53     1. document=1, weight=1, published=Thu Apr  1 22:20:07 2010, author_id=1
    54     2. document=2, weight=1, published=Thu Apr  1 23:25:48 2010, author_id=1
    55     3. document=3, weight=1, published=Thu Apr  1 12:01:00 2010, author_id=2
    56 
    57     words:

    出现ERROR:
    using config file '/usr/local/coreseek/etc/video.conf'...
    indexing index 'video'...
    ERROR: source 's_video': unknown type 'MySQL'; skipping.
    ERROR: index 'video': failed to configure some of the sources, will not index.
    total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
    total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg

    安装mysql支持
    yum install mysql-devel libxml2-devel expat-devel
    重新编译

    编译错误一
    make[2]: *** [indexer] Error 1
    make[2]: Leaving directory `/www/tmp/csft-3.1/src'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/www/tmp/csft-3.1/src'
    make: *** [all-recursive] Error 1
    In the meantime I've change the configuration file and set

    #define USE_LIBICONV 0 in line 8179.
    修改configure 文件把 #define USE_LIBICONV 0 最后的数值由1改为0
    重新编译。

  • 相关阅读:
    BZOJ1093 [SCOI2003]字符串折叠
    BZOJ1078 [SCOI2008]斜堆
    BZOJ1089 [SCOI2003]严格n元树
    BZOJ1031 [JSOI2007]字符加密
    BZOJ1038 [ZJOI2008]瞭望塔
    BZOJ1037 [ZJOI2008]生日聚会Party
    BZOJ1041 [HAOI2008]圆上的整点
    BZOJ1026 [SCOI2009]windy数
    linux命令行计算器 <转>
    正则的[]与()
  • 原文地址:https://www.cnblogs.com/laushow/p/9086808.html
Copyright © 2011-2022 走看看