将 Sphinx 与 PHP 和 MySQL 结合使用的指南
我正在寻找使用 Sphinx 与 PHP 和 MySQL 的完整指南。我想要一个比网站上提供的更简单、更随和的版本。
我正在寻找一些关于它到底如何运作的概念。
我有一个带有 PHP、HTML、其他数据和 MySQL 数据库的服务器。我将如何设置 Sphinx 来支持搜索和返回结果?
我希望能够将搜索词传递给 PHP 脚本并让它处理 Sphinx 并返回数据。
PS 我也愿意接受有关 Sphinx 的任何其他替代方案的建议。
I'm looking for a complete guide to using Sphinx with PHP and MySQL. I'd like one that's a bit simpler and easygoing than the one provided on the site.
I'm looking for a few concepts on how exactly it all works.
I have a server with PHP, HTML, other data and a MySQL database. How would I go about setting up Sphinx to power the search and results being returned?
I'd like to be able to pass my search terms to my PHP script and have it deal with Sphinx and return the data.
P.S. I'm also open to suggestion regarding any other alternatives to Sphinx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我看到这篇文章,但没有找到我想看到的答案。这是我的快速入门指南:
1。 使用 Homebrew 在 Mac 上安装 Sphinx
:
在 Amazon Linux (CentOS) 上使用 yum 安装:
2.创建Sphinx配置
Sphinx附带配置模板。在 configs 目录中查找 sphinx.conf.dist:
在安装了 Homebrew 的 Mac 上:
在安装了 yum 的 Amazon Linux 上:
它非常简单,但对于新手来说可能包含太多设置。在这种情况下,您可以使用这个简单的配置:
我向此配置添加了 max_matches 设置,因为在一切正常运行后我的第一个问题是“为什么我总是只得到 20 个搜索结果?”。使用 max_matches 您可以设置搜索结果数量的限制。
3.使用索引器创建索引
4.运行Sphinx守护进程
5。安装 PHP Sphinx 扩展
在 Mac 上使用 Homebrew:
在 Amazon Linux 上使用 yum:
6。从 PHP 查询索引
如果出现任何错误,您可以使用以下方法获取更多信息:
7.保持最新索引
要保持最新索引,您可以使用两个索引:
每次重新索引增量索引时,它都会与主索引合并
按照此链接 http://www.sphinxconsultant.com/sphinx-search-delta-indexing/ 了解有关此方法的更多信息。
我发现有用的链接:
I came across this post but didn't find an answer I wanted to see. So here is my Quick Start Guide:
1. Install Sphinx
On Mac with Homebrew:
On Amazon Linux (CentOS) with yum:
2. Create Sphinx config
Sphinx comes with config template. Look for sphinx.conf.dist in the configs directory:
On Mac installed with Homebrew:
On Amazon Linux installed with yum:
It is pretty straightforward but might contain too many settings for a newbie. In such case you can use this simple config:
I added max_matches setting to this config because my first question after I got everything working was "Why do I always get only 20 search results?". With max_matches you can set the limit for search results number.
3. Create index using indexer
4. Run Sphinx daemon
5. Install PHP Sphinx extension
On Mac with Homebrew:
On Amazon Linux with yum:
6. Query your index from PHP
In case of any errors you can get more information with the following method:
7. Keep up to date index
To maintain an up to date index you can use two indices:
Every time delta index is re-indexed it is merged with the main index
Follow this link http://www.sphinxconsultant.com/sphinx-search-delta-indexing/ to read more about this approach.
Links I found useful:
我不太确定什么是好的指南,但这是我的步骤。
a) 下载并安装它非常简单
b) 创建您的第一个索引 - 您需要一个源,一个位置,给定的配置非常好,记住您可以使用主要源来配置所有主要区域,然后其他源从中衍生出来。每个源都应该以主键开头,我发现最好执行 key_id AS id
c) 使用搜索测试索引
d) 启动 sphinx 的搜索恶魔 - searchd 这是 php 将连接到的内容以及它如何获取结果。
e) 创建一个函数来搜索所有索引,传入您要搜索的索引,它将返回与您的搜索匹配的数组中的 id
f) 进行增量并更新。
工作完成 - sphinx 论坛非常好,如果您需要任何帮助,应该可以为您提供。
理查德
I'm not too sure about a good guide but here are my steps.
a) Download and install it's quite straightforward
b) Make your first index - you need a source a location the given config is very good remember you can use a primary source to config all the main areas and then other sources stem off from that. Each source should start with the primary key and I find it works best to do key_id AS id
c) Test you index using the search
d) Start your search demon for sphinx - searchd this is what php will connect to and how it gets your results.
e) Make a function to search all indexes pass in the index you want to search and it will return the ids in an array that have matched your search
f) Make a delta and updates.
Job done - the sphinx forum is very nice and should provide you if you need any help.
Richard
查看 php.net 上的搜索引擎扩展:http: //php.net/manual/en/refs.search.php。
Take a look at Search Engine Extensions at php.net: http://php.net/manual/en/refs.search.php.
http://play.manticoresearch.com/ 是一组交互式课程,将引导您完成不同的任务人们在使用 Sphinx/Manticore 时遇到的问题以及如何解决这些问题。
http://play.manticoresearch.com/ is a set of interactive courses that will walk you through different tasks people come across when using Sphinx/Manticore and how they can be solved.