FTSearch (Database - Java)

Conducts a full-text search of all the documents in a database.

Defined in



public DocumentCollection FTSearch(String query)
    throws NotesException
public DocumentCollection FTSearch(String query, int max)
    throws NotesException
public DocumentCollection FTSearch(String query, int max, int sortopt, int otheropt)
    throws NotesException


String query

The full-text query. See the section "Query Syntax" that follows.

int max

The maximum number of documents you want returned from the query. Set this parameter to 0 to receive all matching documents (up to 5,000. See Usage section).


Integer. Use one of the following constants to specify a sorting option:

  • Database.FT_SCORES (default) sorts by relevance score. When the collection is sorted by relevance, the highest relevance appears first. To access the relevance score of each document in the collection, use the FTSearchScore property in Document.
  • Database.FT_DATECREATED_DES sorts by document creation date in descending order.

  • Database.FT_DATECREATED_ASC sorts by document creation date in ascending order.

  • Database.FT_DATE_DES sorts by document date in descending order.

  • Database.FT_DATE_ASC sorts by document date in ascending order.


Integer. Use the following constants to specify additional search options. To specify more than one option, use a logical or operation.

  • Database.FT_FUZZY specifies a fuzzy search.
  • Database.FT_STEMS uses stem words as the basis of the search.

Return value


A collection of documents that match the full-text query, sorted by the selected option. If no matches are found, the collection has a count of 0.


This method is the same the same as FTSearchRange minus the start parameter.

If the database is not full-text indexed, this method works, but less efficiently. To test for an index, use the IsFTIndexed property. To create an index on a local database, use the updateFTIndex method.

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 in 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.

This method searches all documents in a database. To search only documents found in a particular view, use the FTSearch method in View. To search only documents found in a particular document collection, use the FTSearch method in DocumentCollection.

If you don't specify any sort options, you get the documents sorted by relevance score. If you ask for a sort by date, you don't get relevance scores. A Newsletter object formats its doclink report with either the document creation date or the relevance score, depending on the sort options you use in the document collection.

If the database has a multi-database index, you get a multi-database search. Navigation through the resulting document collection may be slow, but you can create a newsletter from the collection.

Query syntax

To search for a word or phrase, enter the word or phrase as is, except that search keywords must be enclosed in quotes. Remember to escape quotes if you are inside a literal.

Wildcards, operators, and other syntax are permitted. For the complete syntax rules, see "Refining a search query using operators" in Notes® Help. Search for "query syntax" in the Domino® Designer Eclipse help system or information center (for example, http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp), both of which include Notes®.