Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Slapping together a search engine for your database is easy with PHP and MySQL.
So you've got a dynamic site, filled with all sorts of user inputs, whether it be a 'phorum', or like my own site at knowpost.com. The site htdig.org will take care of indexing and searching your html pages, but if you are like me, you have very few html pages, and must of your "content" resides in BLOBs in your database. You can't do anything useful using a like %searchword% query, it just isn't coming back relevant.
There has to be a better way, and indeed there is, with a few easy steps. Here's how to slap one together:
Part one: BNR--Blob Noise Reduction
The first problem with your content is that it is filled with clunky "noisewords," like "a,the,where,look" Things that are there to help us humans to communicate, but really don't have anything to do with relevance. We gotta get rid of those. I've included a big list of noisewords (noisewords.txt) for you to use, modify or mutilate. Essentially, what we're trying to do here is get all those noisewords out of your data, and build a table with two columns, the word, and its indicator (the content associated with it). We want something that will eventually look like this:

+------+------------+
| qid  | word       |
+------+------------+
|    6 | links      |
|    5 | Fire       |
|    5 | topics     |
|    5 | related    |
|    5 | Shakespeare|
|    4 | people     |
|    4 | Knowpost   |
|    3 | cuba       |
|    3 | cigar      |
+------+------------+
Lets create our table now--

CREATE TABLE search_table(
word VARCHAR(50),
qid INT)
Next Page


Comments:
search using multiple search fieldsMatthew Daniels11/27/05 19:58
RE: display records 1-10 then next/prev.saleem05/12/05 09:01
Searching with mysql+php.siti 12/06/04 22:54
RE: Searching mysql...Barend11/01/04 06:37
Another Good, Free ScriptDaniel Hendricks01/28/03 02:07
RE: database searching/zureash12/03/02 13:27
DB Search across different headdingsRichmond Chua09/27/02 19:13
Identifier?Jason Nelms09/11/02 12:00
RE: Building a search engine(spider)Beldwin Cabrera08/26/02 01:55
RE: display records 1-10 then next/prev.Eviljello08/23/02 11:53
READERS: Ignore this articleVan07/15/02 00:39
RE: search engineMoses Bony06/27/02 18:26
RE: Building a search engine(spider)Vince06/22/02 09:02
implementing search engineMarge06/13/02 01:58
RE: Searching mysql...Alessandro05/29/02 17:56
Searching mysql...Vic Jolin05/27/02 03:46
RE: Fixed Scriptdmitry05/07/02 04:10
RE: Weird SQLBill Barron05/03/02 13:24
starting a search engineShunte Carter05/03/02 12:14
Weird SQLDemon 32105/01/02 11:59
using links indexingYuriC04/29/02 16:22
problem in search ... help meDeV^AwaY04/24/02 19:42
why blobs?bob_whale04/18/02 22:22
search engineayman04/05/02 16:59
RE: Boolean searchesAqil02/28/02 02:51
Build a search engine in MySQL muthu02/18/02 00:24
RE: Fixed ScriptPaddy02/13/02 10:17
Fixed ScriptJose01/21/02 18:17
The search query in this article is bogus.Jose01/21/02 17:51
Simple Question I am sureKacey A. Murphy01/17/02 12:19
RE: Close Match Search on DBPavan01/14/02 09:29
mySQL 3.23.23 Has All This Built InFigment01/08/02 12:15
RE: Can someone look at this?Mark Hall12/10/01 19:57
Can someone look at this?TVance12/05/01 15:38
PLEASE SOMEONE HELP!!!...TVance12/05/01 15:15
RE: And when the created table is dropped?Danny Biggs12/02/01 23:59
Code and other requirements for search enginerubina12/01/01 01:52
where is the solution?rubina12/01/01 01:41
Building a search engine(spider)Aditya11/26/01 13:47
Building a search engine(spider)Aditya11/25/01 13:39
RE: creating a search engine which can do elantra11/20/01 02:29
Pretty Cool Search engine, but..Luis Erique11/19/01 11:05
knowpostPamela Weston10/20/01 20:28
Simple but Powerful ImprovementBefara10/04/01 00:19
RE: search engineCameron Cox09/03/01 06:27
Problem with resultOwen08/31/01 00:02
Using multiple keywordsTantalus08/16/01 19:35
boolean (and/or) search on php/mysql datatbasdread08/16/01 02:03
query on page 2 of this articleJesse07/27/01 00:47
And when the created table is dropped?Alkis Doulgeris07/12/01 06:06
Another TweakDan07/10/01 09:58
search engineAnitaamal07/04/01 22:13
RE: full text search engineDanny Tuppeny06/28/01 04:26
RE: search engineDmitry06/13/01 05:42
creating a search engine which can do shzshi06/12/01 04:09
Normalization (and / or why?)Rutger Lubbers06/06/01 11:26
RE: Close Match Search on DBJimmy Brake05/25/01 14:56
RE: Close Match Search on DBThomas Hurst05/20/01 13:44
Close Match Search on DBShekhar05/13/01 23:24
full text search engineRobin Ren05/05/01 18:09
RE: search engineShanx05/03/01 14:38
search enginerobert04/24/01 18:04
Extra points for words close togetherDarian Stibbe04/05/01 09:54
RE: That's great -- but here's a better versionAndy Jeffries03/26/01 11:14
deja vunadia03/20/01 11:23
RE: Efficiency...Simone Capra03/08/01 15:02
more php/mysql search scriptsJohn Scrivener02/24/01 06:32
this query has a subselectScott Mebberson02/11/01 16:34
RE: Anyone care to put this article in English?Mangala02/08/01 18:43
RE: Need help getting started with this srch-engSummerblind02/08/01 06:27
str_replace instead of ereg_replace??Allen02/04/01 02:04
RE: Efficiency...Szii02/03/01 16:04
Search engines for those without SQLOliver White02/01/01 10:43
RE: That's great -- but here's a better versionJohn G.01/25/01 07:20
RE: That's great -- but here's a better versionMarc01/21/01 19:48
RE: Boolean searchesJaco Schieke01/14/01 19:48
Efficiency...Phil01/13/01 15:25
RE: display records 1-10 then next/prev.aris01/10/01 20:32
erm, PHP?James01/08/01 13:11
Anyone care to put this article in English?Mr. Needs Help01/05/01 17:40
RE: display records 1-10 then next/prev.Cesar Hernandez01/05/01 15:07
RE: Error on line 4 of codeJamie01/04/01 10:29
display records 1-10 then next/prev.Chris B01/04/01 08:47
RE: Boolean searchescolin01/02/01 11:10
RE: database searchingAdam Gossage12/28/00 21:13
That's great -- but here's a better versionJohn G12/25/00 22:12
Error on line 4 of codeChris Thompson12/22/00 20:55
database searchingCiaran12/18/00 11:31
FANTASTICbharat11/30/00 07:37
Need help getting started with this srch-engTejas11/28/00 22:34
RE: case sensitive or case insensitive?Jeff Harris11/27/00 22:45
RE: How do I reindex?Mike10/07/00 07:43
How do I reindex?Aaron Nikula09/03/00 15:59
Speed of this search engineOlli Kay08/21/00 13:54
Boolean searchesBen Phillips08/08/00 06:00
case sensitive or case insensitive?Wincent Colaiuta08/06/00 05:29
RE: Stupid question about data tablesTim Patterson08/02/00 15:26
Stupid question about data tablesCymen Vig07/18/00 15:25
search engineAmita Jalla07/01/00 05:26
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.