Updating Collections

Unless your Verity collection is indexed from data that never changes, at some point in time you will need to make updates to it. Whether it is to add a new record to the collection or delete one, updating a Verity collection is an important part of keeping your searchable content current.

Adding New Records to a Collection

New records can easily be added to an existing Verity collection using one of two methods. The first method consists of purging the Verity collection of all records and repopulating it. This is done by setting the action attribute of the cfindex tag to Refresh. This method ensures that your Verity collections always contain the most up-to-date information. The disadvantage to this method is that it can be relatively time-consuming for larger collections because it has to completely reindex a collection just to add a single record. The following syntax shows how to use the cfindex tag to purge and reindex a collection:

<!--- Purge and repopulate a collection using the refresh property of the 
      action attribute --->
<cfquery name="IndexNews" datasource="ProgrammingCF">
    SELECT ArticleID, Title, Article 
    FROM News 
</cfquery>
<cfindex collection="News" action="Refresh" type="Custom"  
         body="Title,Article" key="ArticleID" title="Title" query="IndexNews">

The second method is to add the new record by appending it to the end of the collection. This is simple to do using the cfindex tag and offers the advantage of a relatively quick update time. By setting ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.