Displaying Search Result From The View

Displaying Search Result From The View

For the past 7 days I’ve been searching for an article that will solve my problem on displaying search result from a view just like the search facility of Notes. All I found are articles on how to make the search faster but after the search how will it be displayed. The method from LotusScript “PutAllInFolder” (1000+ documents) takes a very long waiting time (3-4 minutes) when executed. That’s why I decided to look for a work around here in developerWorks. Is there a function in C API that can be added to LotusScript in order to copy the function in Notes Search Facility that displays the result in the view.

Thank you.

Mon

Subject: Displaying Search Result From The View

Hi Mon , Please let me know if you are trying to search from Notes Client or web.Actually even I am facing the problem in searching and displaying documents in notes client.

regards ,

Vignesh

Subject: RE: Displaying Search Result From The View

Hi Vignesh,

Yes, I’m searching from Notes Client. Here’s my code.

Sub SearchFullTextAndFields

Dim db As notesdatabase

Dim docSearch As New notesdocument( s.currentdatabase )

Dim coll As notesdocumentcollection

Dim dateTime As New notesdatetime( Now )

On Error Goto errorHandling

Set db = s.currentdatabase

Call dateTime.AdjustDay(-10000)

’ Display the search dialog box

If Not uiwork.dialogbox(“DialogSearch”, True, True, False, False, False, False, msgTitleSearch$, docSearch ) Then Exit Sub

’ create search string

searchString$ = GetSearchCriteria( docSearch )

strMaxDocs = “100” ’ max doc’s returned from search

’ Search

If searchString$ <> “” Then Set coll = db.Search( searchString$, dateTime, 0 ) '==> Searching is fast…

’ countFound

If coll Is Nothing Then countFound% = 0 Else countFound% = coll.count

’ Exit if nothing found

If countFound% = 0 Then

Msgbox msgNoDocumentsFound$, MB_ICONINFO,

msgTitleMain$

Exit Sub

End If

Call coll.putallinfolder(“Search”) '==> Displaying search result (1000+ docs) it took 3-4 minutes waiting time.

uiwork.viewrefresh ’ in case search initiated from folder

If IDOK = Msgbox ( msgFoundDocs$ & Cstr(countFound%) & " documents" & Chr(10) , MB_ICONINFORMATION + MB_OK, db.Title ) Then

End If

Exit Sub

errorHandling:

Print “Search.SearchFullTextAndFields reports:”

Print Cstr(Err) & " " & Error

Resume Next

End Sub

Subject: Displaying Search Result From The View

Hi Mon,Here is a agent code for Search. i m serching documents which will user enter in the form . Form contains 2 field LotNo and Dept i guess.it will search all document and display it like a view. first value is a link . once u click that that document will open.I wish it will help u. to open document via link i have a field on my main form from where we r creating all documents. i m taking path from there.

Sub Initialize

Dim Session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim collection As NotesDocumentCollection 

Dim doc As notesDocument 

Dim doc1 As notesDocument 

Dim webFilePath As String, URLBaseVue As String 

Dim nbDocs As Integer, countDocs As Integer, i As Integer

Set db=Session.currentdatabase

Set doc1= session.DocumentContext 

Dim j As Integer

Dim searchstring As String,path As String



'Creating Search String



If doc1.tLotNum(0) <>""Then	

	searchstr1$= searchstr1$ +doc1.tLotNum(0)

End If	



If doc1.tDepartment(0) <>""Then	

	searchstr1$= searchstr1$ +"&"+doc1.tDepartment(0)

End If	





If searchstr1$ <> "" Then          

	

'removing the first & (and) keyword

	

	If Left(searchstr1$,1) = "&" Then searchstr1$= Right( searchstr1$, Len(searchstr1$) - 1)

End If	



Set view = db.GetView( "TESTING VIEW" )

j = view.FTSearch( searchstr1$, 250 )

If j >0 Then

	

	Set doc = view.GetFirstDocument

	URLBaseVue1 =Cstr(doc.productionUrl(0))+"/0/"

	Print|<BODY TEXT="000000" BGCOLOR="C0E1FF">|

	Print|<BR> 

      <DIV ALIGN=center><B><FONT SIZE=5>Search Results</FONT></B><BR>

      </DIV><BR>|

	Print|<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>

      <TR VALIGN=top><TD WIDTH="272"><DIV ALIGN=center>Tracking Number</DIV></TD><TD WIDTH="272"><DIV ALIGN=center>Department</DIV></TD></TR>

      </TABLE>|

	Print |<table width=50%>|	

	'loop thru collection

	

	For i = 1 To j

				' open TABLE tag

		

		Print|<BR>

	

	<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>

	<TR VALIGN=top><TD WIDTH=272><DIV ALIGN=center><a href="| & URLBaseVue1 & doc.UniversalID & |"> |& Cstr(doc.trackNo(0)) &|  </a></DIV> </TD><TD WIDTH="272"><DIV ALIGN=center>|&Cstr(doc.dept(0)) &|</DIV></TD></TR>

	</TABLE>|

		

		Set doc = view.GetNextDocument(doc)

	Next

	Print |</table>|

Else

	Print|<BR> 

	<DIV ALIGN=center>    </DIV><B><FONT SIZE=5 COLOR="3F803F">No Documents Found  </FONT></B><BR>

	<BR>|

	

End If

End Sub

Subject: RE: Displaying Search Result From The View

Hi, your code looks interesting, but isn’t it made for a web client? I am fighting with the same problem on Notes client, and i have the same boring problem when i copy the search results to a private folder… it takes a long time… could you explain better your posted code? Thanks!

Ciao

Alberto Ernestini

ISA SPA

Subject: RE: Displaying Search Result From The View

Hi Mudit,

Thanks for the code. I’ll try this and let you know the result.

Again thank you.

Mon