coreseek中文搜索

coreseek的安装和使用

准备软件包

coreseek-3.2.14.tar.gz

其他汁源

coreseek中文索引-示例文件.zip

sphinx配置文件详解.txt

1.安装组件

yum -y install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel

2.安装mmseg

$ cd /usr/local/tools/

$ tar xf coreseek-3.2.14.tar.gz

$ cd coreseek-3.2.14/mmseg-3.2.14

$./bootstrap

$./configure --prefix=/usr/local/mmseg

$ make && make install

3.安装coreseek

$ cd /usr/local/tools/coreseek-3.2.14/csft-3.2.14

$ sh buildconf.sh

$./configure --prefix=/usr/local/coreseek  --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ --with-mysql

$ make && make install

4.修改配置文件, 导入测试数据

$ vi /etc/ld.so.conf

/usr/local/mysql/lib  ##新增一行

$ ldconfig

$ cd /usr/local/coreseek/etc

$ cp sphinx-min.conf.dist example.conf

##修改example的配置文件 (示例文件在压缩包内)

##导入example.sql的测试数据(示例文件在压缩包内)

$ echo "" > /usr/local/coreseek/var/log/searchd_example.pid  ##生成进程文件

5.开始测试

##启动服务

$ /usr/local/coreseek/bin/searchd --config  /usr/local/coreseek/etc/example.conf

using config file ‘/usr/local/coreseek/etc/example.conf‘...

listening on all interfaces, port=9312

rotating index ‘example‘: success

##重建索引

$ /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/example.conf --all --rotate

using config file ‘/usr/local/coreseek/etc/example.conf‘...

indexing index ‘example‘...

collected 4 docs, 0.0 MB

sorted 0.0 Mhits, 100.0% done

total 4 docs, 193 bytes

total 0.016 sec, 11577 bytes/sec, 239.95 docs/sec

total 2 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg

total 7 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg

rotating indices: succesfully sent SIGHUP to searchd (pid=100199).

##停止服务

$ /usr/local/coreseek/bin/searchd --config /usr/local/coreseek/etc/example.conf --stop

using config file ‘/usr/local/coreseek/etc/example.conf‘...

stop: succesfully sent SIGTERM to pid 100199

##php端测试

$ cp /usr/local/tools/coreseek-3.2.14/testpack/api/sphinxapi.php /usr/local/httpd/htdocs/  ##复制sphinx类文件(示例文件在压缩包内)

vi /usr/local/httpd/htdocs/test.php  ##新建测试脚本(示例文件在压缩包内)

<?php

require_once(‘sphinxapi.php‘);

$s = new SphinxClient();

$s->SetServer(‘127.0.0.1‘,‘9312‘); //设置searchd的主机名和TCP端口

$s->SetConnectTimeout(1); // 设置连接超时

$s->SetMatchMode(SPH_MATCH_BOOLEAN); //设置全文查询的匹配模式

$page_size=20;//自己定义的页数

$s->SetLimits($start,$page_size); //设置返回结果集偏移量和数目

$s->SetSortMode( SPH_SORT_EXTENDED,"group_id DESC" ); // 设置排序

$s->SetArrayResult(true);//控制搜索结果集的返回格式

$res = $s->Query($keyword,‘*‘);// 执行搜索查询

$res_list = $res[‘matches‘];

echo "<pre>";

print_r($res_list);

?>

  

重启example的索引服务, 然后在浏览器访问: http://localhost/test.php

如果OK将会看到输出...

;

时间: 2024-07-29 22:54:44

coreseek中文搜索的相关文章

coreseek 中文搜索和高亮

配置文件 # # Minimal Sphinx configuration sample (clean, simple, functional) # source post { type = mysql sql_host = 192.168.33.90 sql_user = root sql_pass = root sql_db = test sql_port = 3306 # optional, default is 3306 sql_sock = /tmp/mysql.sock sql_qu

Linux下PHP+MySQL+CoreSeek中文检索引擎配置

说明: 操作系统:CentOS 5.X 服务器IP地址:192.168.21.127 Web环境:Nginx+PHP+MySQL 站点根目录:/usr/local/nginx/html 目的:安装coreseek中文检索引擎,配置MySQL数据库访问接口,使用PHP程序实现中文检索. CoreSeek官方网站: http://www.coreseek.cn/ http://www.coreseek.cn/products/=%22/products-install/step_by_step/ h

coreseek 中文检索

简单介绍:最近有人在问我,说mysql5.6既然已经支持了Innodb的全文索引了,为什么依然有人在使用sphinx这样的软件针对mysql 数据库呢. 第一:目前仍然后很多公司在使用mysql5.5,针对innodb 存储引擎则需要全文索引的软件来帮忙 第二:mysql并不是一款中国人开发的服务,因此对中文分词的支持是不行的,由此引出接下来所要讲解的coreseek 中文检索 因有童鞋对安装和基本使用有困惑,因而将本人的基本操作写上,如有疑问请留言 安装 稳定版 wget http://219

solr中文搜索倒排索引和数据存储结构

作为搜索,我们传统的方式(正排索引)是从关键点出发,然后再通过关键点找到关键点代表的信息中能够满足搜索条件的特定信息,既通过KEY寻找VALUE.而Lucene的搜索则是采用了倒排索引的方式,即通过VALUE找KEY.而在中文全文搜索中VALUE就是我们要搜索的单词,存放所有单词的地方叫词典.KEY是文档标号列表(通过文档标号列表我们可以找到出现过要搜索单词VALUE的文档).正排索引从文档编号找词: 倒排索引是从词找文档编号: 当文档数据来临时,solr会首先对文档数据进行分词,创建索引库和文

helm-mode打开文件支持中文搜索

.title { text-align: center; margin-bottom: .2em } .subtitle { text-align: center; font-size: medium; font-weight: bold; margin-top: 0 } .todo { font-family: monospace; color: red } .done { font-family: monospace; color: green } .priority { font-fami

如何解决Firefox浏览器地址栏中文搜索速度很慢

一.插件安装 之前使用Chrome浏览器,习惯在地址栏中直接进行中文搜索.转到Firefox之后,突然发现在地址栏进行中文搜索,访问速度会很慢. 可以使用插件解决这个问题:Omnibar 插件地址:https://addons.mozilla.org/zh-CN/firefox/addon/omnibar/ 二.添加搜索引擎 安装之后默认使用Google搜索,如图. 由于一些原因,Google搜索可能不能使用,所以这里要更改搜索引擎. 点击Google --> Manage Search Eng

中文搜索翻页乱码问题

使用中文作为关键字搜索,当结果条数很多的时候,肯定会用到翻页.一般的翻页做法,是采用get方式提交.这种情况下翻页,搜索关键字作为参数,会附在url后传递,到后台的时候,已经乱码.返回页面显示当然也是乱码的.解决的代码如下: keyWord = new String(keyWord.getBytes("ISO-8859-1"),"utf-8"); keyword即为传递到后台的搜索关键字. 中文搜索翻页乱码问题

Codeigniter 集成sphinx搜索 这里采用的是coreseek中文搜索引擎,具体安装请参考官方网站

先上效果图 加入sphinx类库(/application/libraries/sphinx_client.php) 0001 <?php 0002 0003 // 0004 // $Id: sphinxapi.php 2055 2009-11-06 23:09:58Z shodan $ 0005 // 0006 0007 // 0008 // Copyright (c) 2001-2008, Andrew Aksyonoff. All rights reserved. 0009 // 0010

添加coreseek中文分词

官方说明地址: ?http://www.coreseek.cn/opensource/mmseg/ 词典文件所在位置: 本地管理地址:xxx/dict/new_dict.txt[ 每次添加新的词,先更新此文件, 然后再把最新的词典文件scp上传到sphinx所在服务器上更新词库] 线上词库配置地址: /export/coreseek/dict/ Step1: 生成词典文件 找出需要添加的词,存储到txt文档中,每个”词条“一行[请检查new_dict.txt中是否已经存在] php 脚本输出格式