In part 1, the article discussed document based searches that display results based on the number of search
words found in each document. This article is an extension that ranks based on number of search words found
plus number of occurrences of each search word in the document.
To search for php tutorials and examples, the following table shows the title and occurrence of each search
word in the document. Common words like is, was, and etc. are removed from the search constraints by the program.
So in this example, we have three search words, php, tutorials and examples.
No.
Article Number
php
Tutorial
Examples
Total Occurrence
Rank
1.
Article #189
15
11
16
42
3
2.
Article #203
25
12
8
45
1
3.
Article #257
18
16
5
39
4
4.
Article #145
6
8
17
31
5
5.
Article #526
5
17
21
43
2
6.
Article #86
14
4
10
28
6
Article #203 has the highest occurrence and it is given rank 1. Similarly ranking is given for other results.
Building The Database:
The database consists of three tables. Document Table, Keyword Table and Link Table. Document Table holds
articles title, and abstract. Keyword Table holds keyword and the keyword field is indexed. Link Table holds keyword
id, content id, and occurrences.
The SQL Statement for creating these three tables are shown below.
Content Table:
CREATE TABLE content (
contid mediumint NOT NULL auto_increment,
title text NOT NULL,
abstract longtext NOT NULL,
PRIMARY KEY (contid)
) TYPE=MyISAM;