设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> 网络编程 >> 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 构建自定义搜索引擎(7)
  清单 9. Body Parts 的示例 sphinx.conf

source catalog
{
 type = mysql

 sql_host = localhost
 sql_user = reaper
 sql_pass = s3cr3t
 sql_db = body_parts
 sql_sock = /var/run/mysqld/mysqld.sock
 sql_port = 3306

 # indexer query
 # document_id MUST be the very first field
 # document_id MUST be positive (non-zero, non-negative)
 # document_id MUST fit into 32 bits
 # document_id MUST be unique

 sql_query = \
SELECT \
 id, partno, description, \
 assembly, model \
FROM \
 Catalog;

 sql_group_column = assembly
 sql_group_column = model

 # document info query
 # ONLY used by search utility to display document information
 # MUST be able to fetch document info by its id, therefore
 # MUST contain '$id' macro
 #

 sql_query_info = SELECT * FROM Inventory WHERE id=$id
}

index catalog
{
 source = catalog
 path = /var/data/sphinx/catalog
 morphology = stem_en

 min_word_len = 3
 min_prefix_len = 0
 min_infix_len = 3
}

searchd
{
 port = 3312
 log = /var/log/searchd/searchd.log
 query_log = /var/log/searchd/query.log
 pid_file = /var/log/searchd/searchd.pid
}

  底部的 searchd 部分将配置 searchd 守护程序本身。该部分中的条目不言自明。query.log 尤为有用:它将在运行时显示每次搜索并显示结果,例如搜索的文档数和匹配总数。

  构建和测试索引

  您现在已经准备好为 Body Parts 应用程序构建索引。为此,需要执行以下步骤:

  键入 $ sudo mkdir -p /var/data/sphinx 创建目录结构 /var/data/sphinx
  假定 MySQL 正在运行,使用如下所示的代码运行索引器来创建索引。

  清单 10. 创建索引

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

using config file '/usr/local/etc/sphinx.conf'...
indexing index 'catalog'...
collected 8 doCS, 0.0 MB
sorted 0.0 Mhits, 82.8% done
total 8 docs, 149 bytes
total 0.010 sec, 14900.00 bytes/sec, 800.00 docs/sec

共10页 9 7 [1] [2] [3] [4] [5] [6] [7] [8] [9] [108 :>

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