# CFINDEX

Use the CFINDEX tag to populate collections with indexed data. CFINDEX and CFSEARCH encapsulate the Verity indexing and searching utilities. Verity collections can be populated from either text files in a directory you specify, or from a query generated by any ColdFusion query. Before you can populate a Verity collection, you need to create the collection using either the CFCOLLECTION tag or the ColdFusion Administrator. Use CFSEARCH to search collections you populate with CFINDEX.

### Syntax

    <CFINDEX COLLECTION="collection_name"
        ACTION="action"
        TYPE="type"
        TITLE="title"
        KEY="ID"
        BODY="body"
        CUSTOM1="custom_value"
        CUSTOM2="custom_value"
        URLPATH="URL"
        EXTENSIONS="file_extensions"
        QUERY="query_name"
        RECURSE="Yes/No"
        EXTERNAL="Yes/No"
        LANGUAGE="language">

#### COLLECTION

Required. Specifies a collection name. If you are indexing an external collection (EXTERNAL is "Yes"), specify the collection name, including fully qualified path:

    COLLECTION="e:\collections\personnel"

You cannot combine internal and external collections in the same indexing operation.

#### ACTION

Optional. Specifies the index action. Valid entries are:

- Update -- Updates the index and adds the key specified in KEY to the index if it is not already defined.
- Delete -- Deletes the key specified in KEY in the specified collection.
- Purge -- Deletes data in the specified collection leaving the collection intact for re-population.
- Refresh -- Clears data in the specified collection prior to re-populating it with new data.
- Optimize -- Optimizes the specified collection of files. This action is deprecated; use CFCOLLECTION instead.

#### TYPE

Optional. Specifies the type of entity being indexed. Default is CUSTOM. Valid entries are:

- File -- Indexes files.
- Path -- Indexes all files in specified path that pass EXTENSIONS filter.
- Custom -- Indexes custom entities from a ColdFusion query.

#### TITLE

Required when TYPE="Custom". Specifies one of the following:

- A title for the collection
- A query column name for any TYPE and a valid query name

The TITLE attribute allows searching collections by title or displaying a separate title from the actual key.

#### KEY

Optional. A unique identifier reference that specifies one of the following:

- Document filename when TYPE="File"
- Fully qualified path when TYPE="Path"
- A unique identifier when TYPE="Custom", such as the table column holding the primary key
- A query column name for any other TYPE argument

#### BODY

Optional. ASCII text to index or a query column name. Required if TYPE="Custom". Ignored for TYPE="File" and TYPE="Path". Invalid if TYPE="Delete". Specifies one of the following:

- The ASCII text to be indexed
- A query column name when a valid query name is specified in QUERY

Multiple columns can be specified in a comma-separated list:

    BODY="employee_name, dept_name, location"

#### CUSTOM1

Optional. A custom field you can use to store data during an indexing operation. Specify a query column name for any TYPE and a valid query name.

#### CUSTOM2

Optional. A second custom field you can use to store data during an indexing operation. Usage is the same as for CUSTOM1.

#### URLPATH

Optional. Specifies the URL path for files when TYPE="File" and TYPE="Path". When the collection is searched with CFSEARCH, this path name will automatically be prepended to all file names and returned as the URL attribute.

#### EXTENSIONS

Optional. Specifies the comma-separated list of file extensions that ColdFusion uses to index files when TYPE="Path". Default is HTM, HTML, CFM, CFML, DBM, DBML. An entry of "*." returns files with no extension:

    EXTENSIONS=".htm, .html, .cfm, .cfml, *."

Returns files with the specified extensions as well as files with no extension.

#### QUERY

Optional. Specifies the name of the query against which the collection is being generated.

#### RECURSE

Optional. Yes or No. Yes specifies that directories below the path specified in KEY when TYPE="Path" will be included in the indexing operation.

#### EXTERNAL

Optional. Yes or No. Yes indicates that the collection specified in COLLECTION was created outside of ColdFusion using native Verity indexing tools.

#### LANGUAGE

Optional. To use the LANGUAGE attribute you must have the ColdFusion International Search Pack installed. Valid entries are:

- English (default)
- German
- Finnish
- French
- Danish
- Dutch
- Italian
- Norwegian
- Portuguese
- Spanish
- Swedish

### Example

    <!--- This example shows how to utilize CFINDEX
    to populate an existing collection with content --->
    <HTML>
    <HEAD>
    <TITLE>
    CFINDEX Example
    </TITLE>
    </HEAD>
    <BODY bgcolor=silver>
    <H3>CFINDEX Example</H3>

    <!--- To index the collection, select the check box on the form --->
    <CFIF IsDefined("form.IndexCollection")>
    <CFINDEX ACTION="UPDATE" COLLECTION="Snippets"
      KEY="c:\inetpub\wwwroot\cfdocs\snippets" TYPE="PATH" TITLE="Test"
        URLPATH="http://127.0.0.1/cfdocs/snippets/" EXTENSIONS=".cfm"
          RECURSE="Yes">
    ...