« SonarBuddies | Main| Welcome Abigail Grace »

Domino search method frustration

Category
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

Gravatar Image1 - I got screwed up by the same thing:

Notes://Notes1/00256C3E0030650D/11A0B6A64FFB3D8D85256A4C004F1BBD/0FC6500F06F4926385257363006D30D9

Sometimes the documentation is vague or misleading, and sometimes it is just wrong.

Gravatar Image2 - Thanks. I just read your blog. I was also frustrated and then did a google search and found your blog. This is a strange behaviour of db.search. May I know how did you arrive at a solution then?

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)