After you have your collection in place and your site indexed, you should create a search interface that enables your visitors to submit their queries to the Verity server for comparison against the collection. A simple form such as the one in Figure 20.10 enables the visitor to enter a search term and submit it to a page that displays the results. Figure 20.10. A simple search form that submits a query to Verity.
The results page is where the real search magic takes place. For instance, suppose that the text field in the search form was named tfSearchTerm. The results page needs a snippet of code like the following to begin the search: <CFSEARCH NAME="searchMyCollection" COLLECTION="myCollection" CRITERIA="#FORM.tfSearchTerm#"> This tag compares the content of the tfSearchTerm text field with the data stored in the myCollection Verity collection. Note The value of the COLLECTION attribute must match the name of the collection that you created in the ColdFusion Administrator. To output the search results on the page, add the following code: <CFOUTPUT QUERY="searchMyCollection"> <a href="#URL#">#Title#</a> </CFOUTPUT> This code outputs the results of the searchMyCollection search and displays the Title as a clickable hyperlink. The #URL# and #Title# variables are built-in variables that are returned by the <cfsearch> tag. Some additional variables that you can use include the following:
Using these basic concepts, you should understand how the Verity Search Server can assist you in providing search capabilities to your site visitors. When coupled with SQL queries against the database, this powerful search engine application can assist you in ensuring that your visitors are able to find the information they are looking for. |