Home arrow PHP arrow Performing Full-text and Boolean Searches with MySQL

Performing Full-text and Boolean Searches with MySQL

When a database-driven web site grows past a certain size, it requires an internal search engine. If it is a very big site, it may be desirable for visitors to be able to use full-text searches and Boolean operators to find the information they need. This article, the first of a three-part series, explains why and shows you how to work with full-text and Boolean searches using MySQL and PHP 5.

TABLE OF CONTENTS:
  1. Performing Full-text and Boolean Searches with MySQL
  2. Running SELECT queries using a common approach
  3. Using full-text searches with MySQL
  4. Building the Web Form
By: Alejandro Gervasio
Rating: starstarstarstarstar / 6
June 06, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

These days it's not unusual for developers to find themselves building web sites that use database tables as their back ends. These databases are designed from the very beginning to store plain contents (not HTML output). The popularity of such sites is growing over time with those who build them, since databases allow for easy separation of these contents from their visual presentation.

Naturally, creating maintainable database-driven web sites comes at a cost. The procedure requires the developer to handle a completely separate piece of software, like the database server, in addition to having a basic background in the so-called SQL (Standard Query Language). However, these issues seem to be rather insignificant once a web site is up and running and delivering its database contents quickly and smoothly to different users.

But what happens when the web site in question has grown beyond the expected boundaries and needs an internal search engine? Well, nothing too serious actually. This kind of application can be quickly developed by providing users with a simple web form to enter different search terms, and then implementing the business logic that will return the corresponding results from one or more database tables to visitors.

Nonetheless, the scenario described above can be much more complicated if the hard-coded SQL queries used by the search engine are returning massive amounts of data. This much data can sometimes be irrelevant to certain users, and definitely can consume precious server resources.

In simple terms, can this rather inefficient search engine be improved in some way? Fortunately, the answer to that question is a resounding yes! As you'll possibly know, most modern database servers support the implementation of full-text and Boolean searches. These features can dramatically improve the speed of executed queries and allow users to specify the relevance of certain search terms via simple operators, such as the plus (+) and minus (-) signs, to name the most common ones.

Of course, in this series of articles I'm going to show you how to work with full-text and Boolean searches using MySQL and PHP 5, but the entirety of the code samples that will be developed here can be easily modified to work with a different database server.

Having introduced you to the subject of this series, it's time to move on and discover together the real power of using full-text and Boolean searches with MySQL. Let's begin now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: