User Guide

Table Of Contents
576 Chapter 24: Building a Search Interface
<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 using a query
You can index an individual file using 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 were 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.
To index a file specified by a query:
<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">
To search and display the file:
1.
Create a ColdFusion page that contains the following content:
<!--- Output the record set.--->
<p>Your collection now includes the following items:</p>
<cfoutput query="getEmps">
<p>#Emp_ID# #FirstName# #LastName# #Contract_File#</p>
</cfoutput>
<cfsearch
collection="#Form.collname#"
name="getEmps"
criteria="#Form.Criteria#"
maxrows = "100">
<!--- Output the file name contained in the record set. --->
<cfoutput>
Your search returned #getEmps.RecordCount# file(s).
</cfoutput>
<cfoutput query="getEmps">
<p><table>