Searching Collections
Once you
have created and populated a Verity collection, you will naturally
want to provide a means for users to search its contents. The
cfsearch
tag provides just such capability. Using
the cfsearch
tag, ColdFusion allows you to build
sophisticated searching into your applications. In its simplest form,
cfsearch
can perform the searching operation
directly against a Verity collection without the user having to enter
anything for the search criteria. A popular use for this technique is
in the creation of “top ten” lists
of search terms. This technique is covered later in the
Section 16.7
section of this chapter. For now, let’s take a look
at a basic example that demonstrates how to use the
cfsearch
tag to search a Verity collection without
the user having to enter the search
criteria:
<cfsearch collection="cfdocumentation" name="MySearchQuery" type="Simple" criteria="Verity" language="English" external="No"> <cfoutput query="MySearchQuery"> <a href="/cfdocs/#MySearchQuery.URL#">#MySearchQuery.Title#</a><br> </cfoutput>
The collection
attribute is required and specifies the name of the collection you wish to search or, in the case of externally generated collections, the full path to the collection directory. Multiple collections may be searched provided the collection names or paths are separated by commas. When specifying multiple collections, you can’t mix internal and external collections, nor can you have VDK and K2 collections in the same search operation. ...
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.