Build a Custom Search Engine Using PHP
Although Google and its series of products are almost omnipotent, powerful search engines in the Web form are not very suitable for each site. If the site content has been highly specialized or clearly classified, you need to use sphenders and PHP to create an optimized local search system.
In the Internet era, people hope that information can be packaged like fast food: it can be used quickly and can be divided into very small units (or in bytes ?). In fact, in order to meet the needs of users who are impatient and eager for information, even the most common Web sites now require various menus with quick browsing styles:
· RSS is a pizza courier who delivers freshly baked pizzas to the door.
· Network logs are a local Chinese restaurant that offers your favorite flavor dishes.
· Forums are common (or, more appropriately, food snatching in an "Animal House ).
· Searching is like eating a dinner buffet in a local restaurant: You can always fill your food with dishes, as long as your esophagus-and your chair-can survive.
Fortunately, PHP developers can find various RSS, blogs, and forum software to create or improve sites. In addition, although Google and other search sites are almost omnipotent and implement filtering communication, the search engine does not necessarily adapt to each site.
For example, if the Web site provides hundreds of thousands of brand new and refurbished Porsche car parts, Google may find your site through a broad search, such as Carrera parts, however, for a more specific "used 1991 Porsche 911 Targa headlight bezel" query, it may not produce accurate results.
If the site content is highly specialized, or visitors expect the search function to be similar to a real workflow, therefore, it is best to add a local search system tailored for your site based on the global search engine of the Web (more instances related to specialized search, see "A needle in a billion haystacks ").
This article describes how to add a fast, efficient, open-source, and free search engine to the PHP site. No visible Web site is developed in this article. Instead, focus on the components required to deliver valid search results: databases, indexes, search engines, and PHP application programming interfaces (APIS ).
Access excellent sphflood
To provide a custom search function for a site, you must have the data source and the function of searching for the data source. For Web applications, the data source is usually a relational database, with some built-in search functions (integrity is a simple search operator, the same as the SQL operator LIKE ). However, some searches may be more specific than the searches that can be executed by the database, or the search may be too complex, leading to slow SQL JOIN response.
Haidilao needle
Many sites provide content specific to an industry, occupation, or entertainment, such as medicine, law, music, and car repair. In-depth research into this content may require the use of special tools or training, or the use of only one index to generate relevant practical results.
The following are some common search scenarios that require Custom Search Systems:
· Find all the articles about the Stanley Cup written by Joe Hockey.
· Find the latest driver for the HP LaserJet 3015 All-in-One printer.
· Find the TV clips of dinghuur Jr. on David's late-night talk show.
To accelerate the search, you can reschedule the table and simplify the underlying query (table and SQL query optimization is highly dependent on the mode and engine. You can search for articles and books about database performance online ). In addition, you can add a specialized search engine. Which form of search engine is used depends on the data format (and quantity) and budget. There are many options available: You can connect a Google tool to your network, purchase Endeca or other large commercial search products, or try Lucene. However, in many cases, using commercial products is a little tricky or a waste of operation budget. Lucene did not provide PHP APIs when it was written in July 2007.
As an alternative, sphtracing is an open-source and free search engine that can quickly search for text. For example, in a database with almost 300,000 rows and five index columns