设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> 网络编程 >> PHP实例 >> 用 PHP 构建自定义搜索引擎
精品推荐
PHP实例点击TOP10
·基于mysql的论坛(6)
·我的论坛源代码(六)
·PHP+DBM的同学录程序(3)
·用PHP+MySql编写聊天室
·一个简洁的多级别论坛
·用php+mysql一个名片库程序
·PHP制作的仿百度的站内搜索引擎代码
·用PHP实现验证码功能
·簡繁体转换的class
·PHP教程实例:用PHP脚本生成word文档的程序
网络编程点击TOP10
·C#编写的windows计算器-源代码
·ASP.NET 程序中常用的三十三种代码
·『原创』C#中TreeView类操作全攻略:建立树,新增节点,删除节点,修改节点,拖动节点,与Oracle数据库交互操作(一)
·用C#实现木马程序
·VS.net 2005 Beta 下载地址(Express Edition)
·从零开始学ASP.NET(基础篇)
·"SQL Server不存在或访问被拒绝"问题的解决
·.NET 初 级 读 本
·C#版的网站新闻发布系统
·c#操作word表格
精选专题

用 PHP 构建自定义搜索引擎

作者: 来源:http://www.xgdown.com/ 时间:2007-9-15 8:20:24

用 PHP 构建自定义搜索引擎(8)   注: -all 参数将重构 sphinx.conf 中列出的所有索引。如果不需要重构所有索引,您可以使用其他参数只对部分索引进行重构。

  您现在可以使用如下所示的代码用 search 实用程序测试索引(不必运行 searchd 即可使用 search)。

  清单 11. 用 search 测试索引

$ /usr/local/bin/search --config /usr/local/etc/sphinx.conf ENG
Sphinx 0.9.7
Copyright (c) 2001-2007, Andrew Aksyonoff

index 'catalog': query 'ENG ': returned 2 matches of 2 total in 0.000 sec

displaying matches:
1. document=8, weight=1, assembly=5, model=7
id=8
partno=ENG088
description=Cylinder head
price=55
2. document=9, weight=1, assembly=5, model=3
id=9
partno=ENG976
description=Large cylinder head
price=65

words:
1. 'eng': 2 documents, 2 hits

$ /usr/local/bin/search --config /usr/local/etc/sphinx.conf wind
Sphinx 0.9.7
Copyright (c) 2001-2007, Andrew Aksyonoff

index 'catalog': query 'wind ': returned 2 matches of 2 total in 0.000 sec

displaying matches:
1. document=1, weight=1, assembly=3, model=1
id=1
partno=WIN408
description=Portal window
price=423
2. document=5, weight=1, assembly=3, model=1
id=5
partno=WIN958
description=Windshield, front
price=500

words:
1. 'wind': 2 documents, 2 hits

$ /usr/local/bin/search \
--config /usr/local/etc/sphinx.conf --filter model 3 ENG
Sphinx 0.9.7
Copyright (c) 2001-2007, Andrew Aksyonoff

index 'catalog': query 'ENG ': returned 1 matches of 1 total in 0.000 sec

displaying matches:
1. document=9, weight=1, assembly=5, model=3
id=9
partno=ENG976
description=Large cylinder head
price=65

words:
1. 'eng': 2 documents, 2 hits

  第一条命令 /usr/local/bin/search --config /usr/local/etc/sphinx.conf ENG 在零件号中找到了两个含有 ENG 的结果。第二条命令 /usr/local/bin/search --config /usr/local/etc/sphinx.conf wind 在两个零件描述中找到了子字符串 wind。而第三条命令把结果限定为 model 为 3 的条目。

  编写代码

  最后,您可以编写 PHP 代码来调用 Sphinx 搜索引擎。Sphinx PHP API 非常小并且易于掌握。清单 12 是一个小型 PHP 应用程序,用于调用 searchd 以得到使用上面所示的最后一条命令得到的相同结果(“在属于型号 3 的名称中找到含有 ‘cylinder’ 的所有零件”)。
共10页 9 7 [1] [2] [3] [4] [5] [6] [7] [8] [9] [108 :>

用 PHP 构建自定义搜索引擎 相关文章:
用 PHP 构建自定义搜索引擎 相关软件:
特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
转载请注明来源:http://www.xgdown.com