# Populating and Indexing a Collection

At this point, the new collection is just an empty shell. To populate the collection with indexed data, you can use either of two methods:

- The CF Administrator
- The CFINDEX tag

  You can use the Verity Wizard in ColdFusion Studio to create the templates to make yur documents searchable. To run the wizard, click File > New and select the Verity Wizard from the CFML tab of the New Document dialog.

Note | You can index and search against Verity collections created outside of ColdFusion by using the EXTERNAL attribute of CFINDEX and CFSEARCH.

## Selecting an indexing method

Use the following guidelines to determine which method to use.

Using the CF Administrator or CFINDEX
Use the Administrator if | Use the CFINDEX tag if
--- | ---
You want to index document files. | You want to index ColdFusion query results.
The collection won't be updated very frequently. | You need to dynamically populate or update a collection from a ColdFusion application page.
You want to generate the collection without writing any CFML code. | Your collection needs to be updated frequently.
You want to generate a one-time collection. | Your collection needs to be updated by other people.

### Using ColdFusion Administrator

| To use ColdFusion Administrator to index a collection:

1. Select a collection name in the Verity Collections box.
2. Click Index to open the index page. The selected collection name appears at the top of the page.
3. Enter a single file type or multiple file types separated by commas.
4. Type in the directory path for the collection or click Browse Server and navigate to the directory in which to begin the index.
5. Check the Recursively index subdirectories box if you want to extend the indexing operation to all directories below the selected path.
6. Optionally, you can enter a Return URL to prepend to all indexed files. This allows you to easily create a link to any of the files in the index. A typical entry might be something like`http://localhost/wwwroot/`.
7. If the International Language Search Pack is installed, you can select one of the supported languages.
8. Click Update to begin the indexing process. The time required to generate the index depends on the number and size of the selected files in the path.

As you can see, this interface allows you to easily build a very specific index based on the file extension and path information you enter. In most cases, you do not need to change your server file structures to accommodate the generation of indices.

In your ColdFusion application, you can populate and search multiple collections, each of which can be designed to focus on a specific group of documents or queries, according to subject, document type, location, or any other logical grouping. Searches can be performed against multiple collections, giving you lots of flexibility in designing your search interface.

### Using CFINDEX

| To select which collection to index:

1. Open a new file in Studio.
2. Modify the file so that it appears as follows:

       <HTML>
       <HEAD>
           <TITLE>Select the Collection to Index</TITLE>
       </HEAD>

       <H2>Pick which index you want to build</H2>

       <FORM METHOD="Post" ACTION="collectionindexaction.cfm">
           <P>Enter the collection you want to populate:
           <INPUT TYPE="text" NAME="IndexColl" SIZE="25" MAXLENGTH="35"></P>
           <P>Enter the location of the files in the collection:
           <INPUT TYPE="text" NAME="IndexDir" SIZE="50" MAXLENGTH="100"></P>

           <INPUT TYPE="submit" NAME="submit" VALUE="Index">

       </FORM>

       </BODY>
       </HTML>

3. Save the file as `collectionindexform.cfm`

| To use CFINDEX to index a collection:

1. Open a new file in Studio.
2. Modify the file so that it appears as follows:

       <HTML>
       <HEAD>
       <TITLE>Creating Index</TITLE>
       </HEAD>
       <BODY>
       <H2>Indexing Complete</H2>

       <CFINDEX COLLECTION="#Form.IndexColl#"
           KEY="#Form.IndexDir#"
           ACTION="REFRESH"
           TYPE="PATH"
           URLPATH="#Form.IndexDir#"
           EXTENSIONS=".htm, .html"
           RECURSE="Yes"
           LANGUAGE="English">

       <CFOUTPUT>
           The collection #Form.IndexColl# has been indexed.
       </CFOUTPUT>
       </BODY>
       </HTML>

3. Save the file as `collectionindexaction.cfm`
4. View `collectionindexform.cfm` in your browser, enter values, and then click Index.