Domino Connection : Retrieving Domino documents : First column search match
First column search match
This technique can only be used on views that have a sorted first column.
The method returns a collection of AbtLnNotes from an open view. A string serves as selection condition. The views first sorted column values will be compared to the parameter. All documents that match the initial character sequence will be returned. ("T" matches "Tim", "i" does not match "Tim").
Depending on the structure of the view, the method yields different answer sets: If the view is "flat" (it has no category column specified) all documents matching the search criteria will be returned. If the first sorted column does contain categories, only the first document that matches the search criteria is returned.
Below you will find two code samples that demonstrates how to use the first column search match method. For maximum performance, the sample uses pseudo documents instead of documents. You will learn about pseudo documents in the chapter named 'Using database views'. The first sample uses a flat view of one of the sample databases and explains how to find subsets of documents identified by a key. The database is composed of documents that contain Smalltalk class names and a subset of selectors implemented by the classes. The flat view displays the class names in the first sorted column.
| localConnection sampleDatabase sampleView result |
"Initialize your runtime environment"
AbtLnEnvironment startUp.
"Create a local connection"
localConnection := AbtLnConnection local.
"Open the sample database" sampleDatabase :=
localConnection openDatabase:'VASAMPLE\VAFCLU.NSF'.
"Open the flat view"
sampleView := sampleDatabase openViewNoUpdate: 'Flat'.
"find all documents that match the 'AbtLnE' prefix"
result := sampleView firstColumnSearchMatchPseudoNotes: 'AbtLnE'.
"print the results to the transcript window"
result do: [ :n |
Transcript nextPutAll: ((n at: 'Class'), ' ->',
(n at: 'Methods') printString); cr ].
"close the view"
sampleView close.
"close the database"
sampleDatabase close.
"shutdown the environment"
AbtLnEnvironment shutDown.
The second samples uses the categorized view of the sample database. The first column of the categorized view contains all selectors found in the documents. If you expand a category, you will find each class that implements the selector.
| localConnection sampleDatabase sampleView result |
"Initialize the runtime environment"
AbtLnEnvironment startUp.
"Create a local connection"
localConnection := AbtLnConnection local.
"Open the sample database"
sampleDatabase := localConnection openDatabase:'VASAMPLE\VAFCLU.NSF'.
"Open the categorized view"
sampleView := sampleDatabase openViewNoUpdate: 'Categorized'.
"find all documents that belong to the first category that matches the
'#id' prefix"
result := sampleView firstColumnSearchMatchPseudoNotes: '#id'.
"print the results to the transcript window"
result do: :n | Transcript nextPutAll:
((n at: 'Class'), ' ->',
(n at: 'Methods') printString); cr ].
"close the view"
sampleView close.
"close the database"
sampleDatabase close.
"shutdown the environment"
AbtLnEnvironment shutDown.
Another way to select and access documents is to use the full text search facility. Please refer to Advanced topics for a detailed description.
Last modified date: 01/29/2015