Full-text search has always been a key web technology. People are most concerned about how to find the information they want in the vast amount of information. The famous GOOGLE is a very successful example. Most people on the Internet use GOOGLE to find what they need. Full-text search has two major technical indicators: fast and accurate. Some time ago, I made a News system. The boss had to add the full-text retrieval function and thought about it for a long time before using a very clever method. Now let's share it with you. I hope you can introduce it to others. If you have a better solution, please stay behind :)
First, let's introduce my news system: the basic information of news stored in the database, such as the title, publisher, release time, and name of the main news file. The news subject is a static page in html format (the first is to increase the speed and reduce the pressure on the database. The second problem occurs when the database processes large strings .). The idea of full-text search is: first retrieve all the news from the database, find the news of the subject, and then read the news of the subject into a string through io operations. Remove unnecessary things, such as html tags, and use regular expressions to search for the string. If the matching information is found, record the news. Finally, all qualified News is returned to the user.
The following code is used to enter the query conditions. The query keywords are separated by "+": search. jsp
<Html>
<Head>
<Link rel = "stylesheet" href = "css/style3.css">
<Title> News Search </title>
<Script language = "javascript">
Function subform (){
If (document. zl_form.keyword.value = ""){
Alert ("enter a keyword! ");
Document. zl_form.keyword.focus ();
Return false;
}
Return true;
}
</Script>
</Head>
<Body bgcolor = "# F0F6E2">
<Form name = "zl_form" target = "_ new" method = "post" action = "aftsearch. jsp" onsubmit = "return subform ()">
<Table width = "600" bgcolor = "# F0F6E2">
<Tr>
<Td colspan = "4" height = "10"> </td>
</Tr>
<Tr>
<Td width = "14%"> enter the query keyword: </td>
& Lt; td align = "left" width = "65%" & gt;
<Input size = "50" type = "text" name = "keyword" style = "font-size: 9pt">
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.