LOTUSSCRIPT/COM/OLE CLASSES
Examples: FTSearch method
1. This agent returns all the documents in the current database that contain a user-specified string.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
REM Update full-text index
Call db.UpdateFTIndex(True)
REM Get query and put in quotes
query$ = Inputbox("Enter string to search for", "Query")
If query$ = "" Then Exit Sub
query$ = """" & query$ & """"
REM Get the documents that match the query
Set dc = db.FTSearch( query$, 0, _
FT_SCORES, FT_STEMS)
REM Display Subject for documents matching query
Set doc = dc.GetFirstDocument
While Not(doc Is Nothing)
message$ = message$ & doc.Subject(0) & Chr(10)
Set doc = dc.GetNextDocument(doc)
Wend
Messagebox message$,, _
"Search results " & 1 & " - " & dc.Count
End Sub
2. This agent creates a newsletter of the top ten documents in a database that contain a user-specified string.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim news As NotesNewsletter
Set db = session.CurrentDatabase
REM Update full-text index
Call db.UpdateFTIndex(True)
REM Get query and put in quotes
query$ = Inputbox("Enter string to search for", "Query")
If query$ = "" Then Exit Sub
query$ = """" & query$ & """"
REM Get 10 most relevant documents that match the query
Set dc = db.FTSearch(query$, 10)
REM Send newsletter to yourself
If dc.Count > 0 Then
Set nc = New NotesNewsletter(dc)
Set doc = nc.FormatMsgWithDoclinks(db)
Call doc.AppendItemValue("Form", "Memo")
Call doc.AppendItemValue("Subject", "FT search for: " & query$)
Call doc.Send(False, session.UserName)
End If
End Sub
See Also
FTSearch method
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary