ColdFusion lets you enhance the results of searches by letting you incorporate search features that let users more easily find the information they need. Verity provides the following search enhancements:
Term highlighting lets users quickly scan retrieved documents to determine whether they contain the desired information. This can be especially useful when searching lengthy documents, letting users quickly locate relevant information returned by the search.
To implement term highlighting, use the following cfsearch attributes in the search results page:
Attributes |
Description |
---|---|
ContextHighlightBegin |
Specifies the HTML tag to prepend to the search term within the returned documents. This attribute must be used in conjunction with ContextHighlightEnd to highlight the resulting search terms. The default HTML tag is <b>, which highlights search terms using bold type. |
ContextHighlightEnd |
Specifies the HTML tag to append to the search term within the returned documents. |
ContextPassages |
The number of passages/sentences Verity returns in the context summary (the context column of the results). The default value is 0; this disables the context summary. |
ContextBytes |
The total number of bytes that Verity returns in the context summary. The default is 300 bytes. |
The following example adds to the previous search results example by highlighting the returned search terms with bold type.
Create a search results page that includes term highlighting
Many unsuccessful searches are the result of incorrectly spelled query terms. Verity can automatically suggest alternative spellings for misspelled queries using a dictionary that is dynamically built from the search index.
To implement alternative spelling suggestions, you use the cfsearch tag's suggestions attribute with an integer value. If the number of documents returned by the search is less than or equal to the value you specify, Verity provides alternative search term suggestions. In addition to using the suggestions attribute, you may also use the cfif tag to output the spelling suggestions, and a link through which to search on the suggested terms.
The following example specifies that if the number of search results returned is less than or equal to 5, an alternative search term--which is displayed using the cfif tag--is displayed with a link that the user can click to activate the alternate search.
Create a search results page that provides alternative spelling suggestions
Verity lets you organize your searchable documents into categories. Categories are groups of documents (or database tables) that you define, and then let users search within them. For example, if you wanted to create a search tool for a software company, you might create categories such as whitepapers, documentation, release notes, and marketing collateral. Users can then specify one or more categories in which to search for information. Thus, if users visiting the website wanted to learn about a conceptual aspect of your company's technology, they might restrict their search to the whitepaper and marketing categories.
Typically, you will want to provide users with pop-up menus or check boxes from which they can select categories to narrow their searches. Alternately, you might create a form that lets users enter both a category name in which to search, and search keywords.
Create a search application that uses categories