Examples: Collecting documents by searching

  1. This example creates a full-text index if one does not exist, then finds all documents containing the word "alpha" or the string "beta."
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim doc As NotesDocument
      Set db = session.CurrentDatabase
      If NOT db.IsFTIndexed Then
        Call db.UpdateFTIndex(True)
      End If
      Set collection = db.FTSearch("alpha OR beta",0)
      Set doc = collection.GetFirstDocument()
      While Not(doc Is Nothing)
        Messagebox doc.Subject(0)
        Set doc = collection.GetNextDocument(doc)
      Wend
    End Sub
  2. This example finds all documents containing the string "Valdez" in the Subject field using @Contains from the Notes® formula language.
    Sub Initialize
      Dim session As New NotesSession
      Dim dt As New NotesDateTime("07/15/97")
      Dim db As NotesDatabase
      Dim dc As NotesDocumentCollection
      Dim doc As NotesDocument
      Set db = session.CurrentDatabase
      Set dc = db.Search("@Contains(Subject;""Valdez"")", dt, 0)
      Set doc = dc.GetFirstDocument()
      While Not(doc Is Nothing)
        Messagebox doc.Subject(0)
        Set doc = dc.GetNextDocument(doc)
      Wend
    End Sub