用PHP构建自定义搜索引擎
http://tech.ddvip.com 2007年09月12日 社区交流
内容摘要:虽然 Google 及其系列产品几乎无所不能,但是 Web 形式的强大搜索引擎并不能很好地适用于每个站点。如果站点内容已被高度专业化或已明确分类,那就需要使用 Sphinx 和 PHP 来创建一个优化的本地搜索系统。
Schematic 表
Schematic 表将把零件与部件和车型版本绑定在一起。因此,将使用 Schematic 表来查找组装 1979 J Class 敞篷车引擎的所有零件。Schematic 表中的每行都有一个惟一 ID,一个引用 Inventory 表行的外键,一个标识部件的外键,以及用于引用 Model 表中特定型号和版本的另一个键。各行如清单 4 所示:
清单 4. Schematic 表
CREATE TABLE Schematic (
id int(10) unsigned NOT NULL auto_increment,
partno_id int(10) unsigned NOT NULL,
assembly_id int(10) unsigned NOT NULL,
model_id int(10) unsigned NOT NULL,
PRIMARY KEY (id),
KEY partno_index USING BTREE (partno_id),
KEY assembly_index USING BTREE (assembly_id),
KEY model_index USING BTREE (model_id),
FOREIGN KEY (partno_id) REFERENCES Inventory(id),
FOREIGN KEY (assembly_id) REFERENCES Assembly(id),
FOREIGN KEY (model_id) REFERENCES Model(id)
) ENGINE=InnoDB;
为了强化表的意图,下面是 Schematic 中的一张小型行列表:
INSERT INTO `Schematic`
(`id`, `partno_id`, `assembly_id`, `model_id`)
VALUES
(1,6,5,1),
(2,8,5,1),
(3,1,3,1),
(4,5,3,1),
(5,8,5,7),
(6,6,5,7),
(7,4,7,3),
(8,9,5,3);
搜索表
定义了这些表后,就可以轻松地响应很多搜索:
显示特定型号的所有版本
列出装配特殊型号和版本所需的所有部件
显示构成特定型号和版本的特殊部件的所有零件
来源:ibm 作者:Martin Streicher 责编:豆豆技术应用
- php 正则表达式
- php 入门教程
- php 安装配置
- php 函数专题
- php 函数大全(EN)
- php 5.0 中文手册
- php 4.0 中文手册
- php 程序编码规范标准
- php 常见错误
- php 中文乱码
- php Apache 安装配置
- linux php 安装配置
- windows php 安装配置
- php 十天入门教程
- php 学习笔记
- php smarty 教程
- php 分页专题
- php 类
- php 变量
- php 常量
- php 数组
- php 脚本
- php 入门实例
- php 字符串
- php.ini 配置
- php xml 专题
- php session 教程
- php 对象模型
- 更多php专题……