Agents running on Documents & FT Index

My understanding is a little vague on how FT Indexing works. Any help would be greatly appreciated.

I have made my first LS Agent recently. It runs on, and updates all 50,000+ documents in a Database every morning reflecting in a field how many days old that document is.

This apparently cuases the FT Index to become non-valid afterwards – searching for documents usually will provide no results. Is this currect?

In the Agent, after updating all of the Documents, should I use this code:

Call db.UpdateFTIndex(False)

… to update the Index? It takes a couple of hours to complete.

I am just unsure of the best way to handle this Agent. If anyone is interested in looking at the code and providing some insight on how to better write it it is included below. Again, thank you for any help.


Sub Initialize

On Error Goto processError

'***********************************************************

'* LS Sub-routine to run through all documents in the

'* databbase and mark the DocDaysOld field in each

'* document the number of days old it is by comparing

'* to the doc.created date.

'*

'* by Shawn Ostermann 7/27/04

’ ***********************************************************

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim dateTime As New NotesDateTime("Today")

Dim createdTime As NotesDateTime

Dim daysDifference As Long	

Dim n As Long

Dim selection As String



' Select only the Forms that are "Work Oders"

selection = "Form=""Work Order"""



Set db = session.CurrentDatabase

Set collection = db.search(selection,Nothing,0)

Set doc = collection.GetLastDocument()

Set createdTime = New NotesDateTime(" ")	



n = collection.Count 	' Count and print the total Documents selected	

Print "			ComputeDaysOld Agent is running...."

Print "			There are " & n & " documents in the collection"



n=0 ' Reset document counter	



While Not(doc Is Nothing)

	n=n+1

	createdTime.LSLocalTime = doc.Created

	' Find difference between dates & Devide by total seconds in day

	daysDifference=dateTime.TimeDifference(createdTime)/ 86400 		

	doc.DocDaysOld=daysDifference	

	Call doc.Save( False, True )

	Set doc = collection.GetPrevDocument( doc)

Wend



Print "			ComputeDaysOld Agent is Finished!"

Print  "			FINISHED! There were " & n & " were updated"



Call db.UpdateFTIndex(False) ' Update FTIndex

Print "			Updating FTIndex...."

’ Error trap routine

processError:

Print "Error " & Err() & ": " & Error()

Exit Sub

End Sub