IBM Domino: Script to Enable Full Text Indexes on all mail files

From Wiki
Revision as of 19:36, 27 November 2017 by Ebasso (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Currently the only way to enable full text on All mail files is using Domino Administrator. There is no command line option.

I create a LotusScript Agent to enable this. See code below

Agent must be set as "Agent List" and "All selected documents".

and to run use command

tell amgr run "database.nsf" 'createFTIndex'

Source Code:

%REM
   Agent createFTIndex
   Created Nov 24, 2017 by 
   Description: Enable FT Index on all databases
%END REM
Option Public
Option Declare

Sub Initialize
   Dim session As New NotesSession
   Dim thisdb As NotesDatabase
   Dim db As NotesDatabase
   Dim pos As Integer
   Dim servername As String
   Dim mailpath As String
   Dim options As Long

   Print "Agent createFTIndex - start"
   mailpath = "mail/"
   options& = FTINDEX_ENCRYPTED_FIELDS
   'FTINDEX_ALL_BREAKS (4) To index sentence And paragraph breaks
   'FTINDEX_ATTACHED_BIN_FILES (16) To index attached files (Binary)
   'FTINDEX_ATTACHED_FILES (1) To index attached files (raw Text)
   'FTINDEX_CASE_SENSITIVE (8) To enable case-sensitive searches
   'FTINDEX_ENCRYPTED_FIELDS (2) To index encrypted fields

   'Server name (in canonical format) or leave blank for local server/directory:
   servername = ""

   Set thisdb = session.CurrentDatabase
   Dim dbdir As New NotesDbDirectory(servername)

   Set db = dbdir.GetFirstDatabase(DATABASE)
   While Not db Is Nothing
       
       'Skip databases which you don't have access to
       On Error GoTo Error4060
       'Check to see if this database is in the mail directory
       pos = InStr(db.FilePath, mailpath)
       If pos = 1 Then
           Call db.Open(servername,db.Filepath)
           Print "CurrentDB - " + db.Filepath
           If Not(db.IsFTIndexed) Then
               Print "Create Index - " + db.Filepath
               Call db.CreateFTIndex(options&, False)                    
               'Call db.CreateFTIndex(2, True)
               db.Ftindexfrequency = 1 'daily
           Else
               'Call db.CreateFTIndex(options&, True)
               'MessageBox "Database index recreated",, "FT index"
               Print "Base ja eh FTI " + db.Filepath
           End If
       End If
       GetNextDb:
       Set db = dbdir.GetNextDatabase()
   Wend
   Print "Agent createFTIndex - end"
   Exit Sub
Error4060:
   Print CStr(Err) & " " & CStr(Erl) & " " & Error
   'If the code reaches here then the user does not have access rights.
   Resume GetNextDb
End Sub

Ver também