I don't know whether you noticed it when surfing the Internet: some websites with rich content have a content search engine. Some large commercial or comprehensive websites have powerful website search engines, such as Sohu, Sina, and Yahoo. Its convenient search and query function has left an indelible impression on people. You only need to enter keywords (such as web pages) of the information you want to browse, and click the "Search" button, the "webpage" Information List is displayed in front of you. This is only a basic function of the search engine-search and query.
The author is now responsible for the construction of Shandong search forum in the Internet (http://www.china-sd.net), using the most commonly used development language-ASP development search engine powerful function! Below I will explain to you the implementation code of the main components and some of the functions of the search engine. Please point out any shortcomings!
In this section, I will introduce the components and main functions of search engines.
The composition of a search engine is roughly divided into three parts:
1. Interface: This part is mainly for customers and can be seen. For example, you can view the page after you open search.sina.com.cn.
2. Program: This part mainly executes the code and executes the code according to the customer's search requirements to obtain the search results, which we cannot see.
3. Database: All search engines are inseparable from databases, and even the famous Google.com is no exception. The database is a warehouse for storing search materials. The more data is stored, the more information you get, the more powerful the search engine is.
So is the search engine powerful? What are other shining points? Yes, there are a lot of storage materials in the search engine database. We cannot easily search for or even find the required information, so this database is "dead" and useless, so the program code plays a very important role.
At this point, I should introduce several main functions of the search engine:
1. Search and query: Undoubtedly, this is the most basic function. You can find relevant information that matches the keyword Based on the keyword.
2. pagination: If you find a lot of information on a page, it will make people feel messy. pagination shows that according to people's reading habits, place some content on the first page, and other content on the second and third pages.
3. Search statistics: generally include the quantity of data queried, which can be divided into several pages. Each page contains several materials and the data range on the current page.
4. Search Result orchestration: I think you will not be unfamiliar with the search ranking. These are a comprehensive measure of website search engines earning money, which is also an indispensable feature of powerful search engines; for example, ranking by clicks, charging, and ranking by level.
5. Search for multiple keywords: "If you want to search for information containing multiple keywords, you can use spaces to separate the keywords." This is a piece of text in the Sina search engine layout, add multiple keywords to a text box to search for information.
6. Overall statistics: This is the statistics on some data that the search engine has been activated to date, including "popular search keyword" Statistics, overall statistics on data in the database, statistics on data contained in each category, and so on.
The above functional code is mainly written according to the requirements of the author. You can modify the code I wrote to become the functional code you need.
Well, after a hot section, we can also enter the practical stage. First, we should first create a database to store data. Here I will name the database as information. MDB: use access to create a database. Of course, you can also use sqlserver to create a database.
Create four tables: www, sort, samll, and key)
1. www table: Id --- automatic ID, sitename --- site name, URL --- site link, FAQ --- brief description, key --- keyword, time --- add time, level --- site level, sortid --- category ID, smallid --- category ID, hot --- site clicks.
2. Sort table: Id --- automatic number, sort
3. Small table: Id --- automatic number, small
4. Key table: keyname --- keyword; keyhot --- number of occurrences
Use ASP to establish a connection with the database: conn. asp
Note: the path indicated by server. mappath () is the relative path of the file. Here, conn. asp and information. mdb are in the same directory. I think it's easy for everyone to understand and accept! Well, after we build the database, we can build a powerful search engine. Please look forward to it! Xi ~~~~
Use ASP to create a powerful search engine-fuzzy search
Based on a keyword, you can find the relevant information. The "correlation" here refers to a string containing a keyword similar to this keyword. For example, if the keyword "Shandong" is contained in the data in the database, you must find the keywords "Shandong. The Application of Fuzzy search is actually very simple. You only need to use an SQL statement. Let's take a look at the statement writing method.
In SQL syntax, you will find the following judgment words: Like, not like, and. Like is a very useful symbol. However, in many cases, using it may bring you too much data, so before using it, you 'd better start thinking about what data you want. Not like is the opposite. If you want to retrieve data within a certain range, and you know the start and end of the range in advance, you may wish to use between to determine the word. These judgment words are used according to different environments. Generally, they are most commonly used in combination with like and "%.
Dim SQL, key
Key = request ("key ")
SQL = "select * from www where sitename like '%" & Key & "%' or FAQ like '%" & Key & "%' or key like '%" & Key & "% '"
Note: The purpose of the SQL statement here is to retrieve whether the sitename field in the database contains the key, whether the FAQ field contains the key, and whether the key field contains the key, in this way, the search scope includes "site name", "site brief description", and "site keyword ". If you only want to search for keywords, you only need to use SQL = "select * from www where key like '%" & Key & "%. "Or" is used in "like" to connect. "or" or "means that no matter which like meets the conditions, the output of the searched data must be displayed.
OK. Now, you don't have to check whether or not the execution results can be performed, because most functions of the search engine are written using SQL statements. After introducing the implementation of other SQL statement functions, let's take a look at the results! Don't worry !!