Search Engines

Chapter 8 - Creating a Search System
byGareth Downes-Powellet al.
Wrox Press 2003

The term "search engine" groups a large category of tools. As their name tends to indicate, they all have one thing in common: they search for information from a set of data. There are a wide variety of search engines, ranging from massively powerful ones like Google to the smaller system we'll be creating in this chapter. Google uses around 10,000 computers all linked together. Our search engine will be made of some lines of HTML and PHP code running on our server. The set of data used is also not very comparable: Google has more than 2 billion entries, whereas a hotel with a hundred rooms is a pretty large hotel.

Despite their differences, both of these systems implement the following common functionality:

  1. They both have a user interface. Google's basic user interface consists of a single text field while the hotel's user interface may be very complex.

  2. They both search through a set of data, and return a subset of that data that matches the user input.

  3. And finally, they serve no other purpose than to find information. They provide a gateway to more detailed and accurate information.

How Does a SQL Search Engine Work?

Here's a diagram showing how SQL search engines typically work, and this is the system we'll be following for our application:

click to expand

The User Interface

The user interface (sometimes called UI) design is a very important part of the search engine design. Often web site designers focus on the query building, which is great, but the UI deserves special attention. The more complex you make it, the more information the user will be able to enter to feed the search engine, which might help them find a better result. However, an interface design that is too complex may make it harder to use.

The UI part of the search engine is made up of an HTML page, which can either be a pure HTML page with no dynamically generated code or it can be HTML generated by some PHP code on the server.

Building the Query Dynamically

By "building the query dynamically", I mean that the SQL query is never completely written in the PHP file. Instead, it is constructed "on the fly" each time a search is requested by the user. The code will analyze the input given by the user and insert it into the query.

Execution of the Query

Once the query string has been built it needs to be executed, just like any other SQL query. We will use the PHP MySQL functions to send the query to the MySQL server for execution.

Building a List of the Matched Results

This stage is exactly the same as returning the results from a standard database query. We need to present a nicely formatted display of the results to the user.



Dreamweaver MX PHP Web Development
Dreamweaver Mx: Advanced Php Web Development
ISBN: 1904151191
EAN: 2147483647
Year: 2001
Pages: 88

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net