Search functionality

We are developing a discussion application on web.we have provided a search field to search the all the threads.

we are not using any seperate forms for searching.

Can any body help me how to proceed. This is the first time iam iplementing search functionality on web.

Thanks in advance

Subject: search functionality

Hi Ravi,

According to my view, you can use an WQS(Web Query Save) Agent to achieve the functionality. If you are not using any separate forms for searching, then you can call the WQS agent in the form where the search field exists.

Now once the search query is entered, you can call the agent, which will retrieve the search query and do an document search and finally return the results.

For searching you have two options:

a. Option 1, if you intend to search for documents that match the search query anywhere in the database, then use NotesDatabase.FTSearch method.

b. Option 2, in the other case, if you wish to search documents that are contained in a specific view, then use NotesView.FTSearch method.

Also you can refine your search further by using a NotesDocumentCollection to get the FTSearch results and usin NotesDocumentCollection.FTSearch to refine the search again.

Atlast, the agent would loop through each matching document and thereby construct a HTML representation with the document details included. And can finally output the results via a Print Statement.

Refer Print Statement for more info and also constructing HTML using LotusScript agents.

Hope this helps,

Jason

Subject: RE: search functionality

Thanks for your response. :slight_smile:

I have included the search field with search icon as same as the search field given on this forum.

I have created $$searchtemplatedefault form for displaying the search results with proper CSS.

Can you please give some idea how to display fetched results in this form through WQS agenty?

Subject: search functionality

Hi Ravi,

For presenting the results in the $$View Template you can

construct HTML representation, where you will include the document parameters. Will be something like this:

dim msg as string

dim server as string

dim dbpath as string

'now retrieve server, dbpath values. Use a profile to store the

values or get the server and dbpath using CGI Variables. Refer Notes help for table of CGI variables. Something like Server_Name & @WebDBName will do the trick.

'then begin constructing your HTML with the necessary URL

'computation for each matching document.

'now construct HTML for search results

msg=msg+{<a href=“http://”}+cstr(server)+{“/”}+cstr(dbpath)+{“/viewname/”}+cstr(doc.UniversalID)+{“/?Opendocument”>}+cstr(doc.Title)+{}

'in the code above, if the document has a title or any suject then just show it(the line doc.Title conveys this meaning.)

like this you would do for all the matching documents. Better used in a loop. Finally you will get the HTML representation for entire documents that match the search query.

Finally show it in the specified form that you wish. You have two options here.

a. redirect the current window to show the search results. you will do it by using javscript code like "window.location=“http://server/database/$$resultsform?Openform” or self.location.href=“http://server/database/$$resultsform?Openform

but on using this code the crucial point is to put the constructed HTML results in the window. It needs some googling to determine how to put the content in this window.

b. Use window.open method to open a new pop-up window, where you can show the results. This method is better than the first because you can write to this window using javascript “document.write” method.

you will use something like below in your agent:

print {}

'the above code will open a new pop-up window which will further open the specified form element(you can give your own design elements like form, view etc. for illustrational purposes, i have used $$resultsform here.)

'also by using mywindow.document.write(“text”); method, you can put the HTML content inside the newly opened window.

'The above method has one disadvantage, most browsers will block pop-up’s. so be sure to allow pop-up’s via your browser settings.

Hope that helps,

Jason

Subject: RE: search functionality

Thank you very much…:)I’ll try this.

My requirement will match to option A.

Because the search functionality should be as is the functionality on notes.net forum.

I’ll try your idea. hope it will work fine .