例: FTSearch method (NotesDatabase - LotusScript®)

  1. 次のエージェントは、現在のデータベース内の、ユーザーが指定した文字列を含む文書をすべて返します。
    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. 次のエージェントは、データベース内のユーザーが指定した文字列を含む最初の 10 の文書のニュースレターを作成します。
    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