O'Reilly logo

Programming ColdFusion by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 Advanced Techniques 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 in the same search operation.Entering the name of a Verity ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required