Creating a Collection


The first step in developing a search interface for the ColdFusion application is to define a Verity collection. This is a collection of information that can be indexed and searched as a set. The Verity engine performs searches against these collections.

A Verity collection supports grouping of information for these three basic data types:

  • Text files, such as HTML pages on a Web site and CFML pages.

  • Binary documents, such as Microsoft Word documents and popular spreadsheets.

  • Result sets returned from the <CFQUERY>, <CFLDAP>, and <CFPOP> queries.

A collection can be built from individual documents or from an entire directory tree. You can use files from specific directories to create section-specific search capabilities. This is the fourth datatype supported by Verity.

There are two methods to create a Verity collection:

  • Using ColdFusion Administrator.

  • Using the <CFCOLLECTION> tag.

Creating a Collection Using ColdFusion Administrator

The Verity page of ColdFusion Administrator creates and manages collections. You can use ColdFusion Administrator to either map an existing Verity collection to the ColdFusion environment or create a new collection.

Mapping an existing Verity collection is useful because collections created using standard Verity tools can be used in ColdFusion templates. To create a new collection using ColdFusion Administrator, you need to specify the following:

  • Name. All collections need to be named so that they can be accessed later in the ColdFusion templates.

  • Path. This defines the location where the files related to the collection are stored. The default path is Cfusion\Verity\Collections.

  • Language. Various languages can be selected using the International Language Search pack. By default, all collections are for English.

To create a new collection, perform the following steps:

  1. Open the ColdFusion Administrator Verity Collections page, as shown in Figure 20.1. The documentation collection is listed by default if you used the option to install the ColdFusion documentation. The Verity engine searches for the online documents.

    click to expand
    Figure 20.1: The Verity Collections page.

  2. Enter a name for the collection.

  3. Enter a path for the directory location of the new collection.

  4. Select a language if you don't want to use the default, English.

  5. Select Create a New Collection.

  6. Click Submit Changes.

After you create the collection, its name and full path appear in the Verity Collections list.

To access and use an existing Verity collection in your ColdFusion templates, perform the following steps:

  1. Open ColdFusion Administrator.

  2. Enter the collection alias that you want to use locally in the ColdFusion application.

  3. Enter the path to the collection.

  4. Select a language, if the default isn't desired.

  5. Select Map an Existing Collection.

  6. Click Submit Changes.

After creating a Verity collection, you can perform various operations on it:

  • Index. This helps you create an index of the data for the collection. (This is discussed later in this chapter.)

  • Purge. This empties all the indexed data. It's the reverse of indexing.

  • Repair. This repairs a corrupted collection.

  • Delete. This deletes a collection.

Creating a Collection Using the <CFCOLLECTION> Tag

The <CFCOLLECTION> tag is an alternative to accessing and using ColdFusion Administrator. You can use it to schedule the creation of a collection based on an event, or when you want end users to create collections without going through ColdFusion Administrator.

The following is the syntax for the <CFCOLLECTION> tag:

 <CFCOLLECTION ACTION="action"     COLLECTION="collection"     PATH="implementation directory"     LANGUAGE="language"> 

Here are the required attributes of <CFCOLLECTION>:

  • ACTION. Specifies the action to perform: Create, Repair, Delete, Optimize, or Map.

  • COLLECTION. Specifies a collection name or an alias if the ACTION is Map.

  • PATH. Specifies a path to the Verity collection. The effect of the PATH attribute depends on the ACTION that you specify. This is also a required attribute for the Create and Map actions.

The following code snippet uses <CFCOLLECTION> to create a sample Verity collection:

 <CFCOLLECTION  ACTION="Create" COLLECTION="Sample" PATH="d:\cfusion\verity\collections"> 

You can also map an existing Verity collection, as in the following code snippet:

 <CFCOLLECTION  ACTION="Map" COLLECTION="ExistingCollection" PATH="c:\cfusion\verity\collections"> 




Macromedia ColdFusion MX. Professional Projects
ColdFusion MX Professional Projects
ISBN: 1592000126
EAN: 2147483647
Year: 2002
Pages: 200

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net