Domino search method frustration
Category None
I am posting this here, as much so that I have it in the future and if someone else should face the frustration I did when using the Lotuscript search method.
The Search method, given a selection criteria for a document, returns all documents in a database that meet the criteria.
Syntax Set notesDocumentCollection = notesDatabase.Search( formula$, notesDateTime, maxDocs% )
Parameters
formula$
String. A Notes @function formula that defines the selection criteria.
notesDateTime
A cutoff date. The method searches only documents created or modified since the cutoff date. Specify Nothing to indicate no cutoff date.
maxDocs%
Integer. The maximum number of documents you want returned. Specify 0 to receive all matching documents.
Return value
notesDocumentCollection
NotesDocumentCollection. An unsorted collection of documents that match the selection criteria.
This all works great, except for one little gotcha concerning the maxDocs parameter. If you do indeed use the maxDocs parameter to request a maximum of 5 documents, and and then do a .count on the returned collection, you will get the return value of 5 (assuming at least 5 documents matched the criteria). The problem is the returned document collection actually contains all the documents that matched the search criteria, so lets say you search a db of 10000 documents with the maxdocs set to 5 and 1000 matched your criteria, your .count will return 5 but the collection will contain 1000 documents. This had me banging my head against the wall for a few hours, as my loop was processing all docs in the collection and kept returning way more results than I expected. It turns out there has been a technote on it since R4, I just wish they had put a Please Note in the help.
Related technote: MaxDoc Parameter in LotusScript Search Method Does Not Work
I am posting this here, as much so that I have it in the future and if someone else should face the frustration I did when using the Lotuscript search method.
The Search method, given a selection criteria for a document, returns all documents in a database that meet the criteria.
Syntax Set notesDocumentCollection = notesDatabase.Search( formula$, notesDateTime, maxDocs% )
Parameters
formula$
String. A Notes @function formula that defines the selection criteria.
notesDateTime
A cutoff date. The method searches only documents created or modified since the cutoff date. Specify Nothing to indicate no cutoff date.
maxDocs%
Integer. The maximum number of documents you want returned. Specify 0 to receive all matching documents.
Return value
notesDocumentCollection
NotesDocumentCollection. An unsorted collection of documents that match the selection criteria.
This all works great, except for one little gotcha concerning the maxDocs parameter. If you do indeed use the maxDocs parameter to request a maximum of 5 documents, and and then do a .count on the returned collection, you will get the return value of 5 (assuming at least 5 documents matched the criteria). The problem is the returned document collection actually contains all the documents that matched the search criteria, so lets say you search a db of 10000 documents with the maxdocs set to 5 and 1000 matched your criteria, your .count will return 5 but the collection will contain 1000 documents. This had me banging my head against the wall for a few hours, as my loop was processing all docs in the collection and kept returning way more results than I expected. It turns out there has been a technote on it since R4, I just wish they had put a Please Note in the help.
Related technote: MaxDoc Parameter in LotusScript Search Method Does Not Work
Comments
Notes://Notes1/00256C3E0030650D/11A0B6A64FFB3D8D85256A4C004F1BBD/0FC6500F06F4926385257363006D30D9
Sometimes the documentation is vague or misleading, and sometimes it is just wrong.
Posted by At 10:54:53 AM On 10/03/2007 | - Website - |
Posted by Megha At 05:32:40 PM On 01/16/2009 | - Website - |