|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Populating a Collection from a Query
|
|
|
|
Indexing the result set from a ColdFusion query involves an extra step not required when indexing documents. You need to code the query and output parameters, then point the CFINDEX tag at the result set from a CFQUERY, CFLDAP, or CFPOP query.
|
|
|
|
To index a ColdFusion query:
|
|
|
- Create the collection on the ColdFusion Administrator Verity page.
- Execute a query and output the data.
- Populate the collection using the CFINDEX tag.
|
|
|
|
Indexing database query results |
|
|
|
To populate a collection from a CFQUERY you specify a KEY, which corresponds to the primary key of the data source, and the BODY, the column in which you want to conduct searches. The following extract shows only the CFQUERY and CFINDEX parts of the process.
<!--- Select the entire table --->
<CFQUERY NAME="Messages"
DATASOURCE="CF 4.0 Examples">
SELECT *
FROM Messages
</CFQUERY>
<!--- Output the result set --->
<CFOUTPUT QUERY="Messages">
#Message_ID#, #Subject#, #Title#, #MessageText#
</CFOUTPUT>
<!--- Index the result set --->
<CFINDEX COLLECTION="DBINDEX"
ACTION="UPDATE"
TYPE="CUSTOM"
BODY="MessageText"
KEY="Message_ID"
TITLE="Subject"
QUERY="Messages">
This CFINDEX statement specifies the MessageText column as the core of the collection and names the table's primary key, the Message_ID column, as the KEY value. Note that the TITLE attribute names the Subject column. The TITLE attribute can be used to designate an output parameter.
|
|
|
|
Indexing multiple columns |
|
|
|
To index more than one column in a collection, enter a comma-separated list of column names for values of the BODY attribute, such as:
BODY=FirstName,LastName,Company
|
|
|
|
Custom fields |
|
|
|
The CFINDEX tag supports two custom attributes, CUSTOM1 and CUSTOM2, that you can use to store data during an indexing operation. The query columns you specify as values for these attributes are returned in a CFSEARCH of the collection. For more information on this topic, see the Allaire Knowledge Base article, "Custom1, Custom2 and Summary Fields" (ID# 1081) on our Web site.
|
|
|
|
Advantages of indexing a data source |
|
|
|
The main advantage of performing searches against a Verity collection over using CFQUERY alone is that the database is indexed in a form that provides faster access. Use this technique instead of CFQUERY in the following cases:
- You want to index textual data. Verity collections containing textual data can be searched much more efficiently with CFINDEX than searching a database with CFQUERY.
- You want to give your users access to data without interacting directly with the data source itself.
- You want to improve the speed of queries.
- You want your end users to run queries but not update a database table.
- You do not want to expose your data source.
|
|
|
  
|
|
|
AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.
|