php python java sphinx安装 sphinx全文检索 安装配置和使用 wins10 安装 wins安装

15 篇文章 0 订阅
5 篇文章 0 订阅

sphinx安装 查询 php python java sphinx安装

php python java sphinx安装 sphinx全文检索 安装配置和使用 wins10 安装 wins安装
3.0 - 3.1 下载地址
解压文件 压缩包
将文件 解压 (位置随意放)

在bin 目录底下创建 sphinx.conf文件

source doc
{
    type            = mysql
    sql_host        = 127.0.0.1
    sql_user        = root
    sql_pass        = root
    sql_db          = test
    sql_port        = 3306
    sql_query_pre   = SET NAMES utf8 
    sql_query       =  SELECT * FROM USER
 
}


index testindex
{
    source          = doc
    path            = A:/php/sphinx/data/testindex
    mlock         = 0 
    min_word_len  = 2 
    min_prefix_len = 0
    min_infix_len = 1
    ngram_len     = 1
    ngram_chars = U+4E00..U+9FBB, U+3400..U+4DB5, U+20000..U+2A6D6, U+FA0E, U+FA0F, U+FA11, U+FA13, U+FA14, U+FA1F, U+FA21, U+FA23, U+FA24, U+FA27, U+FA28, U+FA29, U+3105..U+312C, U+31A0..U+31B7, U+3041, U+3043, U+3045, U+3047, U+3049, U+304B, U+304D, U+304F, U+3051, U+3053, U+3055, U+3057, U+3059, U+305B, U+305D, U+305F, U+3061, U+3063, U+3066, U+3068, U+306A..U+306F, U+3072, U+3075, U+3078, U+307B, U+307E..U+3083, U+3085, U+3087, U+3089..U+308E, U+3090..U+3093, U+30A1, U+30A3, U+30A5, U+30A7, U+30A9, U+30AD, U+30AF, U+30B3, U+30B5, U+30BB, U+30BD, U+30BF, U+30C1, U+30C3, U+30C4, U+30C6, U+30CA, U+30CB, U+30CD, U+30CE, U+30DE, U+30DF, U+30E1, U+30E2, U+30E3, U+30E5, U+30E7, U+30EE, U+30F0..U+30F3, U+30F5, U+30F6, U+31F0, U+31F1, U+31F2, U+31F3, U+31F4, U+31F5, U+31F6, U+31F7, U+31F8, U+31F9, U+31FA, U+31FB, U+31FC, U+31FD, U+31FE, U+31FF, U+AC00..U+D7A3, U+1100..U+1159, U+1161..U+11A2, U+11A8..U+11F9, U+A000..U+A48C, U+A492..U+A4C6  
}

indexer
{
    mem_limit       = 128M
}


searchd
{
    listen          = 9312
    listen          = 9306:mysql41
    log         = A:/php/sphinx/log/searchd.log
    query_log       = A:/php/sphinx/log/query.log
    read_timeout        = 5
    max_children        = 30
    pid_file        = A:/php/sphinx/log/searchd.pid
    seamless_rotate     = 1 
    preopen_indexes     = 1
    unlink_old      = 1
    workers         = threads # for RT to work
    binlog_path     = A:/php/sphinx/data
}

修改MYSLQ 链接
修改 sql_query 查询语句
将 A:/php/sphinx/data 这些地址 替换成自己的

打开 DOS 切换到 自己的目录底下, 我的是A:\php\sphinx\bin>
在这里插入图片描述
indexer --config sphinx.conf testindex 先成索引
searchd --config sphinx.conf 再启动服务

生成索引
在这里插入图片描述
启动服务
在这里插入图片描述

在 API文件家里面 引入 类 , 这里引入的是php.的


include "sphinxapi.php";

$cl = new SphinxClient ();
$q = "李杰"; //模拟关键字
$sql = "";
// $mode = SPH_MATCH_ALL;
$host = "127.0.0.1";
$port = 9312;
$index = "*";
$cl->SetServer ( $host, $port );
$cl->SetConnectTimeout(10);
$cl->SetArrayResult(true);
// $cl->SetMatchMode(SPH_MATCH_ALL);
$res = $cl->Query ( $q, $index );
var_dump($res['matches']);

查询结果


array(2) {
  [0]=>
  array(3) {
    ["id"]=>
    int(4118)
    ["weight"]=>
    string(4) "2713"
    ["attrs"]=>
    array(0) {
    }
  }
  [1]=>
  array(3) {
    ["id"]=>
    int(4123)
    ["weight"]=>
    string(4) "2713"
    ["attrs"]=>
    array(0) {
    }
  }
}

OK ,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值