User Guide

Table Of Contents
574 Chapter 24: Building a Search Interface
Using the cfindex tag to index tabular data is similar to indexing documents, with the exception
that you refer to column names from the generated record set in the
body attribute. In the
following example, the
type attribute is set to custom, specifying that the cfindex tag index the
contents of the record set columns Emp_ID, FirstName, LastName, and Salary, which are
identified using the
body attribute. The Emp_ID column is listed as the key attribute, making it
the primary key for the record set.
To index a ColdFusion query:
1.
Create a Verity collection for the data that you want to index.
The following example assumes that you have a Verity collection named CodeColl. You can
use the ColdFusion MX Administrator to create the collection, or you can create the collection
programmatically by using the
cfcollection tag. For more information, see “Creating a
collection with the ColdFusion MX Administrator” on page 553 or “Creating a collection with
the cfcollection tag” on page 555.
2.
Create a ColdFusion page with the following content:
<html>
<head>
<title>Adding Query Data to an Index</title>
</head>
<body>
<!--- Retrieve data from the table. --->
<cfquery name="getEmps" datasource="cfdocexamples">
SELECT * FROM EMPLOYEE
</cfquery>
<!--- Update the collection with the above query results. --->
<cfindex
query="getEmps"
collection="CodeColl"
action="Update"
type="Custom"
key="Emp_ID"
title="Emp_ID"
body="Emp_ID,FirstName,LastName,Salary">
<h2>Indexing Complete</h2>
<!--- Output the record set. --->
<p>Your collection now includes the following items:</p>
<cfoutput query="getEmps">
<p>#Emp_ID# #FirstName# #LastName# #Salary#</p>
</cfoutput>
</body>
</html>
3.
Save the file as collection_db_index.cfm in the myapps directory under the web root directory.
4.
Open the file in the web browser to index the collection.
The resulting record set appears.