Domino Code Fragment

Code Name*
FTSearch
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.129.69.151
Description*
This example will find any documents in the Beginning view that contain the string Method* using the view method FTSearch .
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Note: The FTSearch method should work even if a database is not full text indexed. We have found this to be true for local databases, but not for databases on a server. In order for the function to work on databases on a server, the database must be full text indexed.
Files/Graphics attachments (if applicable): Code:
This example will find any documents in the Beginning view that contain the string Method* using the view method FTSearch. The wildcard will judge any word containing method* as a hit, and will include the document in the resulting NotesDocumentCollection. For details on finding documents in a view using FTSearch, see the document titled Using Full Text Searching to Retreive Documents from a View.

Click here to view the example.

Dim session As New NotesSession 'Declare session as a new Notes session
Dim db As NotesDatabase
'Declare db as a Notes Database
Dim view As NotesView
'Declare view as a Notes View
Dim doc As NotesDocument
'Declare doc as a Notes Document
Dim UpIndex As Integer
'Declare UpIndex as type integer
Dim NumDocs As Integer
'Declare NumDocs as type integer
Dim GotSubject As Variant
'Declare GotSubject as type variant
Set db = session.CurrentDatabase
'Set db to the current Notes database (open)
Set view = db.GetView("Beginning")
'Set view to a view called "Beginning"
If db.IsFTIndexed Then
'If the current is full text indexed
UpIndex = Messagebox("Update database full text index before searching for documents?",51,"Create Index?")
'Ask the user if they would like to force the index to refresh
If UpIndex = 6 Then 'If "Yes" (6 is the return value)
Call db.UpdateFTIndex(True)
'Then use UpdateFTIndex to update the Full Text Index
End If
End If
NumDocs = view.FTSearch("""method*""", 0)
'Search the current Index for "Method*" where the wildcard * will return any words
'beginning with Method
If numDocs <> 0 Then
'If the number of documents found is not equal to 0
Set doc = view.GetFirstDocument()
'set doc to the first document returned
While Not(doc Is Nothing)
'While there are still documents to process
GotSubject = doc.ChapterTitletxt
'Set GotSubject to the current documents field ChapterTitletxt
Messagebox Cstr(GotSubject(0))
'Display the value from the ChapterTitletxt field
Set doc = view.GetNextDocument(doc)
'Set doc to the next document returned
Wend
view.Clear
'Clear the full text results
End If