I’ve noticed that when searching a mail archive db that I’m getting inconsistent results with FTsearch method. I have not been able to find in this forum what the max length for a search string is. Is it 250 (I seem to remember seeing that somewhere)? My code is below.
These are my results: When I do each search separately I get 81 docs with “smith” and 155 with “sullivan-porter”. But together I only get 107. At the very least I should get 155, right?
Here’s my code:
On Error Goto errtrap
Dim s As New notessession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doc2 As NotesDocument
Dim ERRTXT As Variant
Dim strSearchString As String
Set db=s.CurrentDatabase
’ Set folder = db.GetView( “$Inbox” )
Dim dbSearch As New NotesDatabase("nycnotes01","archivedb.nsf")
Dim collection As NotesDocumentCollection
Dim SEARCHTERMS(0) As String
’ SEARCHTERMS(0) =“smith”
SEARCHTERMS(0) ="*sullivan-porter*"
'send to
Dim x As Integer
x=0
Dim SENDstrSearchString As String
For x=0 To Ubound(SEARCHTERMS)
If x=0 Then
SENDstrSearchString=| FIELD SendTo CONTAINS "|+SEARCHTERMS(x)+|"|
Else
SENDstrSearchString=SENDstrSearchString+ | OR FIELD SendTo CONTAINS "|+SEARCHTERMS(x)+|"|
End If
Next
Dim CCstrSearchString As String
’ copyto
x=0
For x=0 To Ubound(SEARCHTERMS)
If x=0 Then
CCstrSearchString=| FIELD CopyTo CONTAINS "|+SEARCHTERMS(x)+|"|
Else
CCstrSearchString=CCstrSearchString+ | OR FIELD CopyTo CONTAINS "|+SEARCHTERMS(x)+|"|
End If
Next
Dim BCCstrSearchString As String
’ blindcopyto
x=0
For x=0 To Ubound(SEARCHTERMS)
If x=0 Then
BCCstrSearchString=| FIELD BlindCopyTo CONTAINS "|+SEARCHTERMS(x)+|"|
Else
BCCstrSearchString=BCCstrSearchString+ | OR FIELD BlindCopyTo CONTAINS "|+SEARCHTERMS(x)+|"|
End If
Next
Dim FROMstrSearchString As String
’ FROM
x=0
For x=0 To Ubound(SEARCHTERMS)
If x=0 Then
FROMstrSearchString=| FIELD From CONTAINS "|+SEARCHTERMS(x)+|"|
Else
FROMstrSearchString=FROMstrSearchString+ | OR FIELD BlindCopyTo CONTAINS "|+SEARCHTERMS(x)+|"|
End If
Next
Dim SMTPstrSearchString As String
’ SMTP
x=0
For x=0 To Ubound(SEARCHTERMS)
If x=0 Then
SMTPstrSearchString=| FIELD SMTPOriginator CONTAINS "|+SEARCHTERMS(x)+|"|
Else
FROMstrSearchString=SMTPstrSearchString+ | OR FIELD SMTPOriginator CONTAINS "|+SEARCHTERMS(x)+|"|
End If
Next
strSearchString=SENDstrSearchString+" OR" + CCstrSearchString+" OR " + BCCstrSearchString +" OR " + FROMstrSearchString +" OR " + SMTPstrSearchString
Msgbox Cstr(Len(strSearchString))+" : " + strSearchString
Stop
’ FT_STEMS
Set collection = dbSearch.FTSearch(strSearchString, 0,,FT_FUZZY)...
Any suggestions for tweaking this code? It does not make sense to loop through the search terms and perform individual searches, does it? That would give me a lot of duplicates I imagine.