There are three main tasks in creating a search tool for your ColdFusion application:
You can perform each task programmatically--that is, by writing CFML code. Alternatively, you can use the ColdFusion Administrator to create and index a collection.
Use the following procedure to quickly create a collection with the ColdFusion Administrator:
You have successfully created an empty collection. A collection becomes populated with data when you index it.
In order for information to be searched, it must be indexed. Indexing extracts both meaning and structure from unstructured information by indexing each document that you specify into a separate Verity collection that contains a complete list of all the words used in a given document along with metadata about that document. Indexed collections include information such as word proximity, metadata about physical file system addresses, and URLs of documents.
When you index databases and other record sets that you generated using a query, Verity creates a collection that normalizes both the structured and unstructured data. Search requests then check these collections rather than scanning the actual documents and database fields. This provides a faster search of information, regardless of the file type and whether the source is structured or unstructured.
Just as with creating a collection, you can index a collection programmatically or by using the ColdFusion Administrator. Use the following guidelines to determine which method to use:
Use the Administrator |
Use the cfindex tag |
---|---|
To index document files |
To index ColdFusion query results |
When the collection does not require frequent updates |
When the collection requires frequent updates |
To create the collection without writing any CFML code |
To dynamically update a collection from a ColdFusion application page |
To create a collection once |
When the collection requires updating by others |
You can use cfcollection action="optimize" if you notice that searches on a collection take longer than they did previously.
Documents are modified frequently in many user environments. After you index your documents, any changes that you make are not reflected in subsequent Verity searches until you re-index the collection. Depending on your environment, you can create a scheduled task to automatically keep your indexes current. For more information on scheduled tasks, see Configuring and Administering ColdFusion.
You can create a Verity search tool for your ColdFusion application in CFML. Although writing CFML code can take more development time than using these tools, there are situations in which writing code is the preferred development method.
Creating a collection with the cfcollection tag
The following are cases in which you might prefer using the cfcollection tag rather than the ColdFusion Administrator to create a collection:
When using the cfcollection tag, you can specify the same attributes as in the ColdFusion Administrator:
Attribute |
Description |
---|---|
action |
(Optional) The action to perform on the collection (create, delete, or optimize). The default value for the action attribute is list. For more information, see cfcollection in CFML Reference. |
collection |
The name of the new collection, or the name of a collection upon which you will perform an action. |
path |
The location for the Verity collection. |
language |
The language. |
categories |
(Optional) Specifies that cfcollection create a Verity Parametric Index (PI) for this collection. By default, the categories attribute is set to False. To create a collection that uses categories, specify Yes. |
You can create a collection by directly assigning a value to the collection attribute of the cfcollection tag, as shown in the following code:
<cfcollection action = "create" collection = "a_new_collection" path = "c:\CFusion\verity\collections\">
If you want your users to be able to dynamically supply the name and location for a new collection, use the following procedures to create form and action pages.
Create a simple collection form page
Create a collection action page
The name and full path of the new collection appear in the list of Verity Collections.
You successfully created a collection, named CodeColl, that currently has no data.
Indexing a collection by using the cfindex tag
You can index a collection in CFML by using the cfindex tag, which eliminates the need to use the ColdFusion Administrator. The cfindex tag populates the collection with metadata that is then used to retrieve search results. You can use the cfindex tag to index either physical files (documents stored within your website's root folder), or the results of a database query.
When using the cfindex tag, the following attributes correspond to the values that you would enter by using the ColdFusion Administrator to index a collection:
Attribute |
Description |
---|---|
collection |
The name of the collection. |
action |
Specifies what the cfindex tag should do to the collection. The default action is to update the collection, which generates a new index. Other actions are to delete, purge, or refresh the collection. |
type |
Specifies the type of files or other data to which the cfindex tag applies the specified action. The value you assign to the type attribute determines the value to use with the key attribute (see the following list). When you enter a value for the type attribute, cfindex expects a corresponding value in the key attribute. For example, if you specify type=file, cfindex expects a directory path and filename for the key attribute. The type attribute has the following possible values:
|
extensions |
(Optional) The delimited list of file extensions that ColdFusion uses to index files if type="path". |
key |
The value that you specify for the key attribute depends on the value set for the type attribute:
|
URLpath |
(Optional) The URL path for files if type="file" and type="path". When the collection is searched with the cfsearch tag, ColdFusion works as follows:
|
recurse |
(Optional) Yes or No. If type = "path" , Yes specifies that directories below the path specified in the key attribute are included in the indexing operation. |
language |
(Optional) The language of the collection. The default language is English Basic. To learn more about support for languages, see Specifying a language. |
You can use form and action pages similar to the following examples to select and index a collection.
Select which collection to index
Use cfindex to index a collection
Indexing a collection with the ColdFusion Administrator
As an alternative to programmatically indexing a collection, use the following procedure to index a collection with the ColdFusion Administrator.
This interface lets you 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.