Executing fulltext queries
There are two basic mechanisms to be used when searching with Domino Connection:
1. Search the whole database for the results - use ftSearch:
2. Search only the documents contained in a certain view of the database - use ftSearch:view:
To execute a fulltext query, you have to specify a number of parameters for the search. Use the AbtLnFTSearchQualifier class to set up a detailed query or pass a String as argument to the ftSearch: method. The result of a fulltext search is a collection of AbtLnNotes which are initialized with their item dictionaries, but not yet filled with data. Use the fill method with each document to read the actual data.
Simple query by String
Here is a step-by-step example how to find all documents in your local names and address book which contain a simple string (i.e. 'Your name' -- please replace this string with your name).
| connection database answerSet |
"Start runtime system"
AbtLnEnvironment startUp.
"Create a connection to local databases"
connection := AbtLnConnection local.
"open the local names and address book"
database := connection openDatabase: 'NAMES'.
"Find out if the database is indexed and create an index if
necessary"
database isIndexed
ifFalse: [ database createIndex ].
"Perform a fulltext query on the database using your user name as
search string"
answerSet := database ftSearch:'Your name'.
"Convert the search results to real documents and print the documents
to the Transcript window"
answerSet do: [ :note |
Transcript nextPutAll: note fill printString ].
"Close the database"
database close.
"Shut down runtime system"
AbtLnEnvironment shutDown.
Advanced query by qualifier
Here is a more complicated example that makes use of the AbtLnSerachQualifier class to specify search options. You will search your mail servers names and address books view named 'People' for certain strings (i.e. 'YourName') , limit the number of search results to two documents and sort the search result by relevance (which is the number of occurrences of the search string).
| connection database answerSet qualifier |
"Start runtime system"
AbtLnEnvironment startUp.
"Open a connection the your mail server"
connection := AbtLnConnection mailServer.
"Open the names and address book on the mail server"
database := connection openDatabase: 'NAMES'.
"Specify a query qualifier containing your user name and limit
the number of result documents to two"
database isIndexed
ifTrue: [
qualifier := AbtLnFTQueryQualifier new
queryString: 'Your Name';
sortByRelevance;
maximumResults: 2.
"Execute the query on the specified view only"
answerSet := database ftSearch: qualifier viewNamed: 'People'.
"Print the results of the query onto the Transcript window"
answerSet do: [ :note |
Transcript nextPutAll: note fill printString ].
]
ifFalse:
"In case the database is not indexed, give up because
you cannot create an index on a remote database"
Transcript nextPutAll: 'NAMES.NSF of mail server is
not indexed, can not search the database'; cr.
].
"Close the database"
database close.
"Shutdown runtime system"
AbtLnEnvironment shutDown.
Last modified date: 01/29/2015