「Sphinx」- 全文搜索引擎

Sphinx and Coreseek

Sphinx

Sphinx 是一种开源的全文搜索引擎,被广泛应用于网站、应用程序、文档、邮件等的搜索和索引功能。Sphinx 支持多种语言,包括 PHP、Python、Java、Ruby 等,具有高效、快速和可扩展性等优点;

Sphinx 的工作原理是基于索引的全文搜索,它把文本数据转换成索引形式,然后根据用户的查询条件搜索出匹配的结果。Sphinx 支持多种查询模式,包括全文查询、布尔查询、短语查询、通配符查询等;

Sphinx 还具有一些高级功能,例如支持实时索引、分布式搜索、自定义分词器、自定义排序规则等。此外,Sphinx 还提供了强大的 API 和 Web 界面,方便用户进行索引管理和搜索结果分析;

总之,Sphinx 是一款强大的全文搜索引擎,能够满足各种搜索需求,并且具有高效、快速、可扩展性等优点,适用于各种规模的应用;

Coreseek

主页:http://www.coreseek.cn 已经关闭

coreseek 是一款基于 sphinx 开源的搜索引擎,专门为用户提供免费的中文全文检索系统,coreseek 被称为带有中文分词的 sphinx,与 sphinx 不同的是 coreseek 增加了一个带有中文分司的词库

目前 coreseek 的官网已经不能访问,且该开源项目已不再维护,但这并不妨碍我们使用 coreseek 进行全文搜索,中文分词

Open Source Search Server v2.1.1-release

Homepage: http://sphinxsearch.com/

Book: http://shop.oreilly.com/product/9780596809539.do%EF%BC%9B 介绍 Sphinx;

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

Download Link: http://sphinxsearch.com/files/sphinx-2.2.11-release.tar.gz

Manual: http://sphinxsearch.com/docs/latest/index.html%EF%BC%9B 源码目录下的 doc/sphinx.html 是当前版本的文档;

Installation: http://sphinxsearch.com/docs/latest/installation.html

编译后产生的二进制文件:

indexer: “全文索引“生成工具;

searchd: 后台服务,负责执行对”全文索引“的搜索;

spelldump: 命令行工具,使用 ispell 或 MySpell 格式的字典从”词形“中提取单词;(sphinx_source_dir/doc/sphinx.html)

indextool: 用于打印”全文索引“的多方面 debug 信息,0.9.9-rc2 开始加入的;

wordbreaker: 分词工具,version 2.1.1 开始加入;

错误列表(Error List)

Error #1

> ./indexer –all

./indexer: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

Solved #1

原因:mysql的安装目录/usr/local/mysql/libmysqlclient.so.20 不在环境变量中

两个办法:
# (1) 修改 /etc/ld.so.conf,或者:

> ldconfig /usr/local/mysql/lib

# 修改环境变量(当然也可以):

> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/

PHP Sphinx Extension

Sphinx Client Manual: http://php.net/manual/en/book.sphinx.php

PECL Sphinx: http://pecl.php.net/package/sphinx

然而。。。。。。根本不需要安装扩展,这是 Version 2.1.1,
在源码目录的 api 文件夹下,有一个 sphinxapi.php,已经提供 API 了,开袋即食;
sphinxapi.php 中:

// WARNING!!!
//
// As of 2015, we strongly recommend to use either SphinxQL or REST APIs
// rather than the native SphinxAPI.
//
// While both the native SphinxAPI protocol and the existing APIs will
// continue to exist, and perhaps should not even break (too much), exposing
// all the new features via multiple different native API implementations
// is too much of a support complication for us.

「使用」