Full-text search in jsp (preferred for SUN Enterprise applications)
Full-text search has always beenWebPeople are most concerned about how to find the information they want in the vast amount of information. The most famousGOOGLEIs a very successful example, most people on the network useGOOGLETo find the content you 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 isHtmlFormat static pages (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 thenIoThe operation reads the subject news into a string. Remove unnecessary items, suchHtmlMark something, and use a regular expression to search for the string. If the matching information is found, the news is recorded. Finally, all qualified news is returned to the user.
The following code is used to enter the query conditions."+"SeparateSearch. jsp (preferred for SUN Enterprise applications)
<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 (preferred for SUN Enterprise Applications)" onsubmit = "return subform ()">
<Table width = "600" bgcolor = "# F0F6E2">
<Tr>
<Td colspan = "4" height = "10"> & nbsp; </td>
</Tr>
<Tr>
& Lt; td width = "14%" & gt;Input Query