search (NotesDatabase - JavaScript)

Given selection criteria for a document, returns all documents in a database that meet the criteria.

Defined in

NotesDatabase

Syntax

search(formula:string) : NotesDocumentCollection

search(formula:string, dt:NotesDateTime) : NotesDocumentCollection

search(formula:string, dt:NotesDateTime, max:int) : NotesDocumentCollection

Parameter Description
formula A Notes® @function formula that specifies the selection criteria.
dt A start date. The method searches only documents created or modified since the cutoff date. Can be null to indicate no cutoff date.
max The maximum number of documents you want returned. Specify 0 to receive all matching documents (up to 5,000).
Return value Description
DocumentCollection An unsorted collection of documents that match the selection criteria.

Usage

This method returns a maximum of 5,000 documents by default. The notes.ini variable FT_MAX_SEARCH_RESULTS overrides this limit for indexed databases or databases that are not indexed but that are running an agent on the client. For a database that is not indexed and is running in an agent on the server, you must set the TEMP_INDEX_MAX_DOC notes.ini variable as well. The absolute maximum is 2,147,483,647.

Examples

This button searches the current database for all documents whose Subject field equals a specified value.
var title:string = database.getTitle();
var formula:string = "Subject=\"" + requestScope.query + "\"";
var dc:NotesDocumentCollection = database.search(formula);
var matches:int = dc.getCount();
requestScope.status = "Search of \"" + title + "\" found " +
matches + " document(s) with Subject = \"" + requestScope.query + "\"";