[coreseek/sphinx学习笔记6]--实例代码



1.环境说明
安装目录:/var/coreseek/coreseek
配置文件:(./etc/sphinx.conf)

#searchd服务配置
searchd
{
        port    = 9312
        log    = /var/coreseek/coreseek/var/log/searchd.log
        query_log    = /var/coreseek/coreseek/var/log/query.log
        read_timeout    = 5
        max_children    = 30
        pid_file    = /var/coreseek/coreseek/var/log/searchd.pid
        max_matches    = 1000
        seamless_rotate    = 1
        preopen_indexes    = 0
        unlink_old    = 1
        listen    = localhost:9306:mysql41
}

#数据源配置
source ztm_sheet_xml_source
{
        type    = xmlpipe
        xmlpipe_command    = cat /var/www/htdocs/myweb/application/data/sphinxforsheet.pipe.xml
        xmlpipe_field     = sh_title
        xmlpipe_field     = sh_intro
        xmlpipe_attr_uint    = sh_id
        xmlpipe_attr_timestamp  = sh_time
        xmlpipe_attr_uint               = sh_uid
        xmlpipe_attr_uint               = sh_subject
        xmlpipe_attr_uint               = sh_question_count
        xmlpipe_attr_uint               = sh_note_count
        xmlpipe_attr_uint               = sh_view_count
        xmlpipe_attr_uint               = sh_share_count
        xmlpipe_attr_uint               = sh_praise_count
        xmlpipe_attr_uint               = sh_download_count
        xmlpipe_attr_uint               = sh_admin_note
        xmlpipe_attr_uint               = sh_year
        xmlpipe_attr_uint               = sh_type
        xmlpipe_attr_uint               = sh_grade
        xmlpipe_attr_uint               = sh_city
}

#索引配置
index ztm_sheet_index
{
        source      = ztm_sheet_xml_source
        path        = /var/coreseek/coreseek/var/data/sheet
        docinfo     = extern
        charset_dictpath     =  /var/coreseek/mmseg3/etc
        charset_type    = zh_cn.utf-8
        ngram_len     = 0
}

2.建立索引的php代码(sphinxindex.php)
<?php
class script_sphinxindexforsheet {
    public static function init() {
        $content = self::getXmlPipeHead();
        $filename = "sphinxforsheet.pipe.xml";
        $f = fopen($filename, "w"); 
        if($f){
            fwrite($f, $content);
        }
        fclose($f);
    }

    public static function generateIndex() {
        self::init();
        $begin = time();
        $min_id = 1; // 最小的id值,最好使用程序获取
        $max_id = 100000;  // 最大的id值,最好使用程序获取

        $begin_id = $min_id;
        $limit = 3000;
        do{
            $time1 = time();
            unset($list);
            $list = self::getSheets($begin_id-1, $begin_id+$limit);
            $begin_id += $limit;
            usleep(300);
        }while(($begin_id-$limit)<=$max_id);
        self::appendXmlPipe(self::getXmlPipeFooter());
    }

    protected static function appendXmlPipe($content){
        $f = fopen("sphinxforsheet.pipe.xml", "a");
        if($f){
            fwrite($f, $content);
        }
        fclose($f);
    }

    protected static function getXmlPipeFooter(){
        $xml = "</sphinx:docset>\n";
        return $xml;
    }

    private static function getSheets($offset, $length) {
        $offset = $offset-1;
	$host = 'localhost:';
	$port = 3306;
	$user = 'root';
	$pwd = 'abc123';
	$dbname = 'test';
	$mysql = mysql_connect($host.$port, $user, $pwd) or die('Could not connect: ' . 
                    mysql_error());
	mysql_select_db($dbname);
	$sql = "select id,uid,create_time,title,intro,subject,question_count,note_count,view_count,share_count,praise_count,download_count,admin_note,type,year,city,grade from sheet where id>$offset and id<$length";
        $ret = mysql_query($sql);
	while ($row = mysql_fetch_assoc($ret)) {
	    $xml .="<sphinx:document id=\"" . $row['id'] . "\">\n";
            $xml .="<sh_title><![CDATA[" . $row['title'] ."]]></sh_title>\n";
            $xml .="<sh_intro><![CDATA[" . $row['intro'] ."]]></sh_intro>\n";
            $xml .="<sh_id>" . $row['id'] ."</sh_id>\n";
            $xml .="<sh_uid>" . $row['uid'] ."</sh_uid>\n";
            $xml .="<sh_time>" . $row['create_time'] ."</sh_time>\n";
            $xml .="<sh_subject>" . $row['subject'] ."</sh_subject>\n";
            $xml .="<sh_question_count>" . $row['question_count'] ."</sh_question_count>\n";
            $xml .="<sh_note_count>" . $row['note_count'] ."</sh_note_count>\n";
            $xml .="<sh_view_count>" . $row['view_count'] ."</sh_view_count>\n";
            $xml .="<sh_share_count>" . $row['share_count'] ."</sh_share_count>\n";
            $xml .="<sh_praise_count>" . $row['praise_count'] ."</sh_praise_count>\n";
            $xml .="<sh_download_count>" . $row['download_count'] ."</sh_download_count>\n";
            $xml .="<sh_admin_note>" . $row['admin_note'] ."</sh_admin_note>\n";
            $xml .="<sh_year>" . $row['year'] ."</sh_year>\n";
            $xml .="<sh_type>" . $row['type'] ."</sh_type>\n";
            $xml .="<sh_grade>" . $row['grade'] ."</sh_grade>\n";
            $xml .="<sh_city>" . $row['city'] ."</sh_city>\n";
            $xml .="</sphinx:document>\n";
	}
	mysql_close($mysql);
        self::appendXmlPipe($xml);
    }

    private static function getXmlPipeHead(){
        $xml =  "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
        $xml .= "<sphinx:docset>\n";
        $xml .= "<sphinx:schema>\n";
        $xml .= "<sphinx:field name=\"sh_title\"/>\n";
        $xml .= "<sphinx:field name=\"sh_intro\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_id\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_uid\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_time\" type=\"timestamp\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_subject\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_question_count\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_note_count\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_view_count\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_share_count\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_praise_count\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_download_count\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_admin_note\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_year\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_type\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_grade\" type=\"int\"/>\n";
        $xml .= "<sphinx:attr name=\"sh_city\" type=\"int\"/>\n";
        $xml .= "</sphinx:schema>\n";
        return $xml;
    }
}
script_sphinxindexforsheet::generateIndex();
?>

3.运行代码,建立索引

cd /var/www/htdocs/myweb/application/script
php sphinxindex.php & 
sleep 5
#index
cd /var/coreseek/coreseek
./bin/indexer -c etc/sphinx.conf --rotate ztm_sheet_index

4.查询(search.php)
<?php
require_once '/var/www/htdocs/myweb/application/lib/sphinx/sphinxapi.php';

class application_biz_searchsheet {
	public function query() {
		$verify = $_POST;
		$key = isset($_REQUEST['k'])?strval($_REQUEST['k']):'';
		$subject = isset($_REQUEST['s'])?strval($_REQUEST['s']):'';

		//年份范围
        $year_min = -1;
        $year_max = -1;
        if(isset($_REQUEST['ymin']) && isset($_REQUEST['ymax'])){
            $year_min = intval($_REQUEST['ymin']);
            $year_max = intval($_REQUEST['ymax']);
        }

        // 城市
        $city = isset($_REQUEST['c'])?intval($_REQUEST['c']):0;

        // 卷子类型
        $arr_type = isset($_REQUEST['t'])?strval($_REQUEST['t']):null;
        $arr_shtype = null;
        if($arr_type){
            $arr_shtype = array();
            foreach($arr_type as $type){
                $arr_shtype[] = intval($type);
            }
        }

        $grade = isset($_REQUEST['g'])?intval($_REQUEST['g']):-1; // 年级
        $page = isset($_REQUEST['p'])?intval($_REQUEST['p']):1; // 页数
        $desc_order_by = "sh_download_count";//默认按照时间排序
        if(isset($_REQUEST['desc'])){
            $desc_order_by = $_REQUEST['desc'];
        }
        $list = $this->search(array(
            'key'=>$key,
            'subject'=>$subject,
            'year_min'=>$year_min,
            'year_max'=>$year_max,
            'city' => $city,
            'arr_shtype'=>$arr_shtype,
            'grade'=>$grade,
            'page'=>$page,
            'pagenum'=>20, 
            'desc_order_by'=>$desc_order_by));

        return array(
            "verify"=>$verify,
            "list"=>$list,
        );
	}

	public function search($condition, $flag = false) {
		$res = $this->searchd($condition);
		$data = array();
		if ($res) {
			$total = $res['total'];
            $total_found = $res['total_found'];
            if($res && isset($res['matches'])) {
            	$matches = $res['matches'];
				// 根据 $matches 的值再去查询数据库,即可获得对应的详细数据
            	foreach ($matches as $row) {
            		$data['sheet'][] = "查询数据库获得的结果";
            	}
            }
            $pagenum = isset($condition['pagenum'])?$condition['pagenum']:10;
            $data['other']['total'] = $total;
            $data['other']['total_found'] = $total_found;
            $data['other']['total_page'] = $total%$pagenum==0?intval($total/$pagenum):intval($total/$pagenum)+1;
		}
		return $data;
	}

	public function searchd($condition) {
        // 关键字
        $key = isset($condition['key'])?strval($condition['key']):'';
        // 当前科目域名
        $subject = isset($condition['subject'])?trim(strval($condition['subject'])):'';
        // 年份下限
        $year_min = isset($condition['year_min'])?intval($condition['year_min']):-1;
        // 年份上限
        $year_max = isset($condition['year_max'])?intval($condition['year_max']):-1;
        // 城市
        $city = isset($condition['city'])?intval($condition['city']):0;
        // 卷子类型
        $arr_shtype = isset($condition['arr_shtype'])?$condition['arr_shtype']:null;
        // 年级
        $grade = isset($condition['grade'])?intval($condition['grade']):-1;
        //分页,从1开始
        $page = isset($condition['page'])?intval($condition['page']):1;
        //每页数量
        $pagenum = isset($condition['pagenum'])?intval($condition['pagenum']):10;
        //用来做降序排列的字段名称
        $desc_order_by = isset($condition['desc_order_by'])?$condition['desc_order_by']:null;//

        try {
        	$client = $this->connect();
            $client->SetMatchMode ( SPH_MATCH_EXTENDED2 );
            $client->SetRankingMode ( SPH_RANK_WORDCOUNT );
            if($desc_order_by){
                $client->SetSortMode (SPH_SORT_ATTR_DESC, $desc_order_by);
            } else {
                $client->SetSortMode ( SPH_SORT_RELEVANCE );
            }
            $sid = isset($condition['sid'])?$condition['sid']:0;
            if($sid>0){
                $client->SetFilter('sh_subject', array($sid));
            }
            // 年份范围
            if($year_min>-1 && $year_max>-1){
                $client->SetFilterRange('sh_year', $year_min, $year_max);
            }
            // 城市
            if($city>0){
                $client->SetFilter('sh_city', array($city));
            }
            // 卷子类型
            if($arr_shtype){
                $client->SetFilter('sh_type', $arr_shtype);
            }
            // 年级
            if($grade>-1){
                $client->SetFilter('sh_grade', array($grade));
            }
            // 分页
            $page = ($page < 1) ? 1 : $page;
            $offset = ($page-1)*$pagenum;
            $client->SetLimits($offset, $pagenum);
            $res = $client->Query ("$key", "ztm_sheet_index");
            return $res;
        } catch (Exception $e) {
            return false;
        }
	}

	protected function connect(){
        try{
            $host = '127.0.0.1';
            $port = 9312;
            $client = new SphinxClient ();
            $client->SetServer ($host, intval($port));
            return $client;
        } catch (Exception $e) {
            return false;
	   }
    }
}
?>
$obj = new application_biz_searchsheet();
$ret = $obj->query($_REQUEST);
$ret 就是搜索结果。

转载于:https://my.oschina.net/wzwitblog/blog/114207

Sphinx + Coreseek 实现中文分词搜索 Sphinx + Coreseek 实现中文分词搜索 Sphinx Coreseek 实现中文分词搜索 全文检索 1 全文检索 vs 数据库 2 中文检索 vs 汉化检索 3 自建全文搜索与使用Google等第三方网站提供的站内全文搜索的区别 Sphinx Coreseek介绍 Coreseek安装使用1. 全文检索1.1 全文检索 vs. 数据库全文检索是数据库的有力补充,全文检索并不能 阅读详情

相关推荐

基于php的Sphinx以及coreseek的全文搜索,中文分词的使用(一)

基于php的Sphinx全文搜索,中文分词的使用 1.什么是sphinx Sphinx是一个基于SQL的全文检索引擎,可以结合MySQL,PostgreSQL做全文搜索,它可以提供比数据库本身更专业的搜索功能,使得应用程序更容易实现专业化的全文检索。Sphinx特别为一些脚本语言设计搜索API接口,如PHP,Python,Perl,Ruby等,同时为MySQL也设计了一个存储引擎插件。 ...

割le动脉he脉动 4876

在java中如何使用sphinx技术(coreseek)

安装好mmseg(中文分词)及csft(coreseek fulltext)之后,进入到csft-3.1.tar.gz解压后的目录csft-3.1。进入其子目录api,再进入其子目录java。使用命令cat readme,可根据它的提示生成 sphinxapi.jar。 将 sphinxapi.jar导入到MyEclipse工程里面,在这里写一个简单的测试代码,访问coreseek: impo

only_silence的专栏 3614

给jetson nano 安装AX200网卡驱动

几经波折,因为在网上看到的基本都是amd版本而非arm版,然后最终选定V5.5是因为更新的几个版本的arm版本是false的(在https://kernel.ubuntu.com/~kernel-ppa/mainline/处选择版本时,得看在arm64上是false还是build succeeded,之前没经验呀刚刚才顿悟的) 1,参考文章https://blog.csdn.net/MIRANA0/article/details/106696334 学到了得下载如下四个: wget https://k

发嘎嘎的博客 2359

CentOS6.2 安装Coreseek(Sphinx)详细教程

Sphinx是一个基于SQL的全文检索引擎,可以结合mysql,postgresql做全文搜索,它可以提供比数据库本身更专业的搜索功能,但对中文检索并不友好。而coreseek就是基于sphinx针对中文搜索研发出来的软件, 适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景。http://blog.rekfan.com/?p=136 Coreseek

sujianxin2012的专栏 1203

MATLAB 2022b 用户专属:保姆级IPOPT求解器安装配置全流程(含OPTI工具箱)

本文为MATLAB 2022b用户提供IPOPT求解器的详细安装与配置指南,涵盖OPTI工具箱的适配安装、环境变量设置及常见问题解决方案。通过实战案例演示非线性优化问题的求解过程,帮助用户高效部署这一强大的优化工具,提升工程计算效率。

weixin_29092031的博客 412

微信小程序 - 真机调试请求异常 Provisional headers are shown,微信小程序开发者工具调试没问题就真机测试时出现请求报错(微信小程序请求接口提示Provisional h)

微信小程序开发 Request Headers: Provisional headers are shown,微信开发工具请求正常,真机调试和上线之后出现 Provisional headers are shown,微信小程序开发工具调试没问题,真机调试Provisional headers are shown,在开发工具调试,请求正常没问题,使用真机调试,请求异常,微信小程序真机调试时后台是本地服务器,显示“Provisional headers are shown”问题解决,微信小程序websocket

🏆 前端领域优质创作者 1万+

Sphinx/Coreseek简介&安装使用

Sphinx/Coreseek简介&安装使用 Sphinx/Coreseek简介       在数据库使用模糊匹配的时候,在数据量少的情况下,使用like '%keywork%'可以解决,但是在数据量大的情况下,查询时间就变得难以忍受了。尤其是访问量大的时候,仅仅靠mysql已经无法支撑业务。Sphinx是一个基于SQL的全文检索引擎,可以结合MySQL,PostgreSQL做全文搜索

zhibin的程序日记 900

使用 Python 爬取 Wikipedia 数据:抓取百科条目及其内容

维基百科的 API 提供了一些方便的接口,通过这些接口,我们可以轻松获取到维基百科的条目、类别、图片和其他相关信息。维基百科的 API 主要是基于 HTTP 请求的,通过向特定的 URL 发送 GET 请求来获取信息。:获取指定条目的内容。在本博客中,我们介绍了如何使用 Python 爬取维基百科的条目数据。通过使用 Wikipedia API 和网页抓取技术,我们能够高效地获取条目内容,并将其存储和分析。希望本篇教程能帮助你深入理解如何抓取和处理维基百科的数据。

2201_76125261的博客 484

sphinx/coreseek 安装全过程

第一:先安装mysql数据库开发包yum install mysql-devel libxml2-devel expat-devel第二:##下载coreseek:coreseek 3.2.14:点击下载、coreseek 4.0.1:点击下载$ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.

Technology world 2720

4、文化遗产数字记录的伦理框架构建

本文探讨了在数字技术快速发展的背景下,如何构建一个伦理框架以指导文化遗产的数字记录工作。文章分析了遗产保护的重要性以及当前面临的挑战,包括气候变化、全球化和技术变革等。同时,结合国际古迹遗址理事会(ICOMOS)的伦理原则和加拿大遗产专业人员协会(CAHP)的行为准则,提出了六个核心伦理类别,并讨论了其在实践中的应用。文章强调,伦理框架不仅有助于提高数字记录的质量和可持续性,还能促进专家合作、保护社区利益并确保数字遗产的长期可访问性。未来需要持续完善这一框架,以应对不断变化的技术和社会环境带来的新挑战。

7h6j5k4l3的博客 103

【数据分享】12.5米分辨率DEM地形数据(分省)

该数据来源于NASA地球科学数据网站(https://nasadaacs.eos.nasa.gov/),是ALOS卫星获取的高精度地形数据。该数据由于精度高,包括全省范围的数据和省内每个城市范围的数据!

JData_Engineer的博客 2188

基于Sphinx的中文全文检索引擎Coreseek的安装

按照Sphinx来进行全文检索,默认只支持按字拆分,如果要实现比较好的中文分词,可以使用基于libmmseg的引擎Coreseek。 yum install g++yum install gccyum install makeyum install mysql mysql-devel php-mysql qt4-mysql wget  http://www.corese

蒋宇捷的专栏 2075

学 Simulink—— 基于强化学习(DDPG)的电机无位置传感器控制仿真

Actor:输入状态s,输出θ̂_dot(即 ω̂),积分得 θ̂Critic:评估"估计角度与反电动势模型一致性"的 Q 值奖励函数不依赖真实 θ(无监督式自监督),只用iαβ预测残差。

amy_mhd的博客 23

Coreseek/Sphinx安装测试配置指南

Coreseek安装测试配置指南 Sphinx--强大的开源全文检索引擎,Coreseek--免费开源的中文全文检索引擎 软件版本:coreseek-4.1           mmseg-3.2.14           autoconf-2.64             老版本的coreseek-3.2和mmseg-3.2.13安装过程一样。 一、安装前准备编译环境 1.1 yu

xuyaqun的专栏 7057

开源大语言模型GLM-5:从架构解析到部署微调全指南

大语言模型(LLM)作为当前人工智能领域的核心技术,通过海量数据预训练获得强大的语言理解和生成能力。其核心原理基于Transformer架构,通过自注意力机制捕捉长距离依赖关系,在通用语言任务上展现出卓越性能。这一技术价值在于为开发者提供了强大的基座模型,能够通过微调快速适配特定领域需求,显著降低AI应用开发门槛。在实际应用场景中,大模型被广泛用于智能对话、代码生成、内容创作等任务。本文以开源项目GLM-5为例,深入探讨其架构特点,并详细介绍了如何使用LoRA技术进行参数高效微调,以及通过量化优化实现模型在

weixin_28683165的博客 355

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

sphinx和coreseek

sphinx是国外的一款搜索软件。 coreseek是在sphinx的基础上,增加了中文分词功能,换句话说,就是支持了中文。 Coreseek发布了3.2.14版本和4.1版本,其中的3.2.14版本是2010年发布的,它是基于Sphinx0.9.9搜索引擎的。而4.1版本是2011年发布的,它是基于Sphinx2.0.2的。Sphinx从0.9.9到2.0.2还是有改变了很多的,有很多功能,...

weixin_30563319的博客 153

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

[ 笔记 ] coreseek/sphinx 全文检索简介

coreseek(sphinx) 全文检索注:本文永久更新链接,markdown格式源码 Github: Aidan Daicoreseeksphinx 全文检索 Coreseeksphinx全文检索的了解 概述 全文检索 sphinx sphinx搜索引擎架构图 sphinx分布式索引原理 sphinx分布式索引配置 coreseek 教程 centos 7 下安装并测试 coreseek

Aidan Dai 1490

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

sphinx,coreseek安装

sphinx是国外的一款搜索软件。 coreseek是在sphinx的基础上,增加了中文分词功能,换句话说,就是支持了中文。 Coreseek发布了3.2.14版本和4.1版本,其中的3.2.14版本是2010年发布的,它是基于Sphinx0.9.9搜索引擎的。而4.1版本是2011年发布的,它是基于Sphinx2.0.2的。Sphinx从0.9.9到2.0.2还是有改变了很多的,有很

罗罗罗罗罗罗健 367

Sphinx与coreseek

Sphinx : 高性能SQL全文检索引擎 分类编程技术 Sphinx是一款基于SQL的高性能全文检索引擎,Sphinx的性能在众多全文检索引擎中也是数一数二的,利用Sphinx,我们可以完成比数据库本身更专业的搜索功能,而且可以有很多针对性的性能优化。 Sphinx的特点 快速创建索引:3分钟左右即可创建近100万条记录的索引,并且采用了增量索引的方式,重建索引非常...

agg7911的博客 283

coreseek/sphinx CentOS6.4下安装

coreseek/sphinx CentOS6.4下安装 一、在CentOS6.4下安装coreseek之前需要预先安装以下软件 1.打开终端 输入 su 获取管理员权限 2.输入命令 yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat

walle的博客 787

ubuntu 安 sphinx /coreseek

http://blog.chinaunix.net/uid-20639775-id-3277497.html http://os.51cto.com/art/201109/288831_all.htm http://sphinxsearch.com/wiki/doku.php?id=sphinx_manual_chinese#indexer%E5%91%BD%E4%BB%A4%E5%8F

u011156212的专栏 1451

Sphinx & Coreseek

Sphinx 使用背景 当对大文本对数据进行单词匹配查询时,如:有一个歌曲网站,数据库中收集着上百万首歌曲的信息,如果要查询出歌词中带“爱情”带所有歌曲,典型的做法是执行如下SQL语句。 select * from songs where content like "%爱情%". 但是在mysql中以%开头的查询无法使用所有,所以这条sql语句将执行权标扫描,性能极差。MylSAM引擎中的...

qq_39642747的博客 319

Coreseek、Sphinx-for-chinaese、Sphinx+Scws区别

Sphinx是一个基于SQL的全文检索引擎;普遍使用于很多网站;但由于中英文的差异,其本身,对中文的支持并不好。 主要体现在对一段话断词;英文只需按照空格对其分词即可;但对于博大精深的中文来说,却是件困难的事情。 分词在两个地方会用到; 1、索引时,根据分词索引原始数据 2、搜索时,对用户输入分词,到索引中查询 本文提供了三种目前最常用的方案Coreseek、Sphinx-for

爱代码也爱超越 901

coreseek sphinx 安装配置

wget http://www.coreseek.cn/uploads/csft/3.1/Source/csft-3.1.tar.gz wget http://www.coreseek.cn/uploads/csft/3.1/Source/mmseg-3.1.tar.gz  安装mmseg $./configure --prefix=/usr/local/mmesg $make $mak

fox1987的专栏 753

coreseek mysql.sock_coreseek sphinx mmseg mysql 全文检索 安装 配置

上次搞全文检索的东西 ,还要追溯到2010了,当时个人觉得coreseek还不成熟,就用了原始的sphinx,请参考:sphinx mmseg mysql 中文分词,这次呢,决定用一下coreseek,看看有什么区别。一,安装环境和工具服务器用的是centos6.5 x86coreseek 4.0.1下载地址:http://www.coreseek.cn/uploads/csft/4.0/cor...

weixin_39980347的博客 150

coreseek/sphinx中的匹配模式

所谓匹配模式就是用户如何根据关键字在索引库中查找相关的记录。 SPH_MATCH_ALL, 匹配所有查询分词(默认模式); 如“手机配件”,不匹配 “我有一部手机”,但可以匹配 “手机坏了,需要找配件”。 因为“手机配件” 被分成 “手机”,“配件”两个词,匹配条件是必须同时包含这两个词,所以“我有一部手机”不符合匹配要求。 SPH_MATCH_ANY, 匹配查询词

红叶的专栏 1万+
上一篇: 《Shell脚本学习指南》读书笔记4-第4章 文本处理工具
下一篇: 在PHP使用kindeditor
chengtou2663
博客等级 码龄10年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值