
501
DEVELOPING
COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Las
t
upda
te
d 8/5/2010
<html>
<head>
<title>Search Results</title>
</head>
<body>
<cfsearch
collection="#Form.collname#"
name="getEmps"
criteria="#Form.Criteria#"
maxrows = "100">
<!--- Output the record set. --->
<cfoutput>
Your search returned #getEmps.RecordCount# file(s).
</cfoutput>
<cfoutput query="getEmps">
<p><table>
<tr><td>Title: </td><td>#Title#</td></tr>
<tr><td>Score: </td><td>#Score#</td></tr>
<tr><td>Key: </td><td>#Key#</td></tr>
<tr><td>Summary: </td><td>#Summary#</td></tr>
<tr><td>Custom 1:</td><td>#Custom1#</td></tr>
<tr><td>Column list: </td><td>#ColumnList#</td></tr>
</table></p>
</cfoutput>
</body>
</html>
4
Save the file as collection_db_results.cfm in the myapps directory under the
web_root
.
5
View collection_db_search_form.cfm in the web browser and enter the name of the collection and search terms.
Indexing a file returned by using a query
You can index an individual file that uses a query by retrieving a table row whose contents are a filename. In this case,
the key specifies the column that contains the complete filename. The file is indexed using the
cfindex
tag as if it is a
document under the web server root folder.
In the following example, the
cfindex
tag’s
type
attribute has been set to
file
, and the specified key is the name of
the column that contains the full path to the file and the filename.
<cfquery name="getEmps" datasource="cfdocexamples">
SELECT * FROM EMPLOYEE WHERE EMP_ID = 1
</cfquery>
<cfindex
query="getEmps"
collection="CodeColl"
action="Update"
type="file"
key="Contract_File"
title="Contract_File"
body="Emp_ID,FirstName,LastName,Contract_File">