Lotus Notes/Domino is a group system based on Internet/Intranet technology. It is one of the main tools for constructing enterprise information networks. As a major technology of Lotus Notes/Domino, information retrieval technology provides users with a variety of methods, including full-text retrieval, keyword-based query, views, and folders. This article combines the experience in actual development, the document query in the Notes application is discussed.
Document Query
---- In Lotus Notes, information is stored in the database as a document. A document is equivalent to a record in a relational database. That is to say, in the NOTES application, the query of information is the query of documents. There are several methods to query documents: View, folder, full-text search. Next we will discuss their characteristics one by one.
---- 1. View
---- A view is the main window for viewing documents in Lotus Notes. Each view contains documents meeting certain conditions. After the selection conditions of a view are specified, the document displayed in the view is a document that meets the conditions. For example, the selection conditions of a view are: Select form = ""; after the view is opened, all the documents we see are requested documents. In addition to selection conditions, a view can also classify and sort documents based on different features so that we can quickly navigate to the document to be searched. For simple queries, You can classify and sort views in a reasonable way without writing any program. The design of the Notes view is a quick step in the application design process. If the database is correctly designed for the first time and has all the required fields available in the correct document, the design view should be an easy process and intuitive for users to print the view displayed on the output screen.
---- 2. the folder is also one of the Document Browsing windows, but unlike the view, the folder has no selection conditions, and the documents in it are put through Putinfolder, you must use RemoveFromFolder to remove the document.
---- 3. Full-text search
---- Full-text search is a search tool provided by Lotus Notes based on the full-text index of the database. It can search the entire database based on the given search keywords and display the search results at the top of the view.
---- 4. query by keyword
---- A good query design should provide accurate and rapid responses to user queries, and display user data accurately and flexibly. To meet users' multi-condition query combinations, developers generally design a "query by keyword" Method for users, you need to write a program so that you can enter one or more query conditions for combined condition query to find documents that meet the conditions. However, because the results cannot be directly displayed in NOTES, the general solution is to store the query results in the folder, and finally open the folder to display the query results.
Folder defects and Solutions
---- Because Lotus Notes documents can be shared and folders can also be shared, you can use this folder to store your search results, I can also use this folder to store my query results, and Lotus Notes should ensure that they do not conflict with each other. Unfortunately, Lotus Notes does not provide this guarantee, resulting in mutual influence and access conflict. To solve this problem, we propose two methods:
---- 1. Create a private folder
---- A private folder is a private folder that is invisible to others. You can create a "private after startup" folder. After each user uses this folder, the system immediately creates a new folder for this user based on the private folder after startup. In this way, each user has a folder with the same structure and no mutual interference. This solution ensures that conflicts are not generated, but the system saves a folder for each user, which may cause system maintenance difficulties. If the system has too many users, the situation will be worse. If the user logs out, its private folder is not automatically deleted.
---- 2. Improved view Method
---- Views are shared by everyone. By improving the selection conditions of views, we can use views as the places where we store query results to avoid folder problems. The solution is to mark the document that meets the query conditions of a user, create a shared view, and use the View Selection Formula to display the query results of the user, after the display or printing is complete, delete the selection tag. The specific implementation method is as follows:
---- (1) Create an implicit field "SelectedUserName" that can edit multiple values on the database document form to be queried to store the user name for querying this document.
---- (2) create a shared view vwSelect with the following formula:
---- SELECT Form = "frmFormName "&
---- @ Contains (SelectedUserName; @ UserName)
---- Used to display the document found by the user
---- (3) create a Navigator "nvgQueryResult" for the display view. Its initial view is vwSelect.
---- (4) search for documents that meet the conditions by using the FTSearch function in the Sript language.
Programming implementation
---- (1) query display
---- Function: query by keyword and display the query result.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Set db = session. CurrentDatabase
Itemvalues = item1.values
Condition = itemvalues (0)
For I = Lbound (itemvalues) + 1
Ubound (itemvalues)
Condition = Condition + itemvalues (I)
'All query conditions entered by the user
Next
Count = view. FTSearch (Condition, 0)
'Complete full-text search
If count <> 0 Then
Messagebox "in this database:" + Str (Count) +
"Records meet the conditions! ", 0 + 64," prompt information"
For j = 1 To count
Set doc = dc. getnthdocument (j)
Set item = doc. GetFirstItem ("SelectedUserName ")
Call item. AppendToTextList (session. UserName)
'In the SelectedUserName Field
Call doc. Save (True, True) 'append User Name
Next
ServerName = session. GetEnvironmentString
("ServerName ")
DirName = session. GetEnvironmentString
("DirectionName ")
DatabaseName = DirName + "DBName. nsf"
'Open the navigator call view to display the query results.
Call workspace. OpenDatabase (ServerName,
DatabaseName,
"NvgQueryResult ")
Else
Messagebox "no matching record!
", 0 + 48," prompt message :"
End If
End
(2) Exit the display
Function: Clear the user selection tag.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Set db = session. CurrentDatabase
'Viewname = session. GetEnvironmentString (
"EnvViewNa ")
Set view = db. GetView (vwSelect)
Set doc = view. GetFirstDocument
UserName = session. UserName
'Get the UserName to the variable: UserName
While Not (doc Is Nothing)
TempValue = doc. SelectedUserName
'Clear the file domain "SelectedUserName"
Doc. SelectedUserName = ""
'Your username;
Call doc. save (True, False)
'Keep the username of another user.
Set item = doc. getfirstitem (
"SelectedUserName ")
Forall x In TempValue
If x <> UserName Then
Call item. AppendToTextList (x)
Call doc. save (True, False)
End If
End Forall
Set doc = view. GetFirstDocument
Wend
End
Key Technical points:
---- The above application design mainly uses the following technical points to ensure the accuracy of the display results and data sharing.
---- (1) the hidden field "SelectedUserName" that can be edited with multiple values created in the database document form to be queried ". fields are an important element in forms. For a NOTES database, external data is input through fields, and data display in the memory of the database depends on fields. Here we create the domain "SelectedUserName" to store the user name to query this document as the selection flag.
Select the flag:
---- Use the user name as the selection flag mainly because the user name is unique in Notes. Different users have different user names and there are no two identical user names. In this way, the domain remembers which different user queries have selected this document. Prepare for displaying the document in the view.
The main attributes of a domain are:
---- Editable: data can be generated by executing Formulas or Script by clicking the button.
---- Implicit: Only for storage, no display function. When a document is displayed, the data in this domain is not displayed. Therefore, you can store multiple values to ensure that all user names of this document are selected under the domain record. Because in the shared data status, the same document can be selected by multiple users at the same time, you must remember all the user names for this document. This is very important for multiple users to display data.
---- (2) view and View Selection Formula:
---- We designed a shared view vwSelect with the following formula:
---- SELECT @ Contains (SelectedUserName; @ UserName)
---- View function: displays all documents containing the current user name in the SelectedUserName field.
---- @ UserName: returns the current user name.
---- @ Contains (SelectedUserName; @ UserName ):
---- Used to determine whether the file domain SelectedUserName contains the current user name, because during the query, the user name is added to the domain "SelectedUserName" that meets the condition document as the selection flag, therefore, this view displays the documents whose domain SELECTEDUSERNAME contains the user name.
---- When designing a view, use the "discard index after opening" option.
Summary
---- To sum up, LousNotes provides a flexible and fast environment for query application development. The methods described in this article can achieve query and retrieval of data documents. However, they have different implementation methods and requirements. Although there are still deficiencies that need to be improved, it still shows some Notes technologies that can be integrated into your application. At the same time, we must be aware that it is very different from the traditional relational database application development system, and the query design has its own unique method, an application can be quickly designed and available. It is difficult to obtain the advantages of the Notes application by attempting to map the traditional application development technology to the developers in the Notes environment.