Table of contents |
Previous |
Next
The differences between FTsearch and DBSearch
In a Domino Web application, besides
searching via Domino URL commands, a designer can implement searches by using the FTSearch and Search (also known as DBSearch) methods for a word or phrase. The
DBSearch method searches for data by using a specific query pattern and returns a set of documents based on the query. FTSearch has better performance than DBSearch, as long as your database is full-text indexed.
FTSearch uses the full text index to search for all documents in a view or database that match a query string. The database does not have to be full text indexed for FTSearch to execute properly. However the search takes longer if it is not. Just like the search method, FTSearch returns a subset of documents based on the search criteria using the NotesDocumentCollection LotusScript class.
These search techniques allow designers to implement search for documents by using conditions and operators based on user inputs that can be passed via custom URL commands. Searching on a view using Domino URL commands works best when the application has a full text index, which makes available advanced search features and faster search capability. However, using FTSearch and DBSearch methods can help find data by using more details.
Examples of search implements
In the following example, we illustrate how to create a custom search results page with content generated by arguments passed by the URL:
1. Create a simple search results form.
2. On this form, create a hidden computed field, called Query_String, that has as value the CGI variable Query_String, that is used to get the query information about the URL.
3. Create a rich text field, called Body, to display your search results. Set this as a computed field with the value Body, and enable pass-through HTML on this field paragraph.
Search results form details
4. Create and set a [WebQueryOpen] agent to this form.
5. Set the right basic and security properties for your [WebQueryOpen] agent, and use the following code on the agent:
6. Create some documents to test your Search() or FTSearch() methods.
7. Invoke the agent by using a URL, for example: http://riverbendcoffee.net/helpdb.nsf/SearchResultsForm?OpenForm&Query=SearchQuery, where SearchQuery is the value searched.
Explanation of the model
The previous example illustrates a custom search interface created on-the-fly for Web users. It uses a form to display links for documents found from a free text search over a database. It has a couple of fields:
- A Query_String field to retrieve the user query portion from the URL
- A rich text repository field (Body) that has as unique function to receive the HTML code generated from the search results
When that form is loaded, it expects to have a
&Query= argument with the free text term the user wants to bring from a database search. This is what the WebQueryOpen agent does in a and simple manner, it get the query value of that argument in Query_String field of the form, and displays the results with links to the users using the
0 view, and the document universal ID.
Search results page
Thus, there could have been much more improvements depending on the application. It could have an input form where the user can use a form to submit search information via form GET, allow users to manipulate the arguments on the URL via buttons or links, display results with a better look and feel using descriptions on tables and style sheets, and much more. However, this is a simple option for search interfaces that does not use Domino URL commands and should be used according to the application needs.
Important
When choosing the methods to implement your search, keep in mind that the Search method has much better performance returning the results than the FTSearch method. Only consider using the FTSearch method in cases where a real full text search is needed. Also, remember that the query syntaxes are different.
|
Tip
When displaying the results on a Web page, consider sorting the collection by a specific parameter. To sort a NotesDocumentCollection collection by a specific criteria, refer to the article How do you sort a document collection?.
|