Indexing a path returned using a query

You can index a directory path to a document (or collection of documents) using a query by retrieving a row whose contents are a full directory path name. In this case, the key specifies the column that contains the complete directory path. Documents located in the directory path are indexed using the cfindex tag as if they were under the web server root folder.

In this example, the type attribute is set to path, and the key attribute is assigned the column name Project_Docs. The Project_Docs column contains directory paths, which Verity indexes as if they were specified as a fixed path pointing to a collection of documents without the use of a query.

To index a directory path within a query:

  1. Create a ColdFusion page that contains the following content:
    <cfquery name="getEmps" datasource="cfdocexamples">
    SELECT * FROM EMPLOYEE WHERE Emp_ID = 15
    </cfquery>
    <!--- Update the collection with the above query results. --->
    <!--- Key specifies a column that contains a directory path. --->
    <cfindex 
    	query="getEmps"
    	collection="CodeColl"
    	action="update"
    	type="path"
    	key="Project_Docs"
    	title="Project_Docs"
    	body="Emp_ID,FirstName,LastName,Project_Docs">
    
    <h2>Indexing Complete</h2>
    <p>Your collection now includes the following items:</p>
    <cfoutput query="getEmps">
    <p>#Emp_ID# #FirstName# #LastName# #Project_Docs#</p>
    </cfoutput>
    
  2. Save the file as indexdir.cfm in the myapps directory.

The ColdFusion cfindex tag indexes the contents of the specified directory path.

To search and display the directory path:

  1. Create a ColdFusion page that contains the following content:
    <cfsearch 
    	collection="#Form.collname#"
    	name="getEmps"
    	criteria="#Form.Criteria#"
    	maxrows = "100">
    
    <!--- Output the directory path contained in 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>
    
  2. Save the file as displaydir.cfm.

View comments in LiveDocs