FTSearchRange (NotesDatabase - JavaScript™)
Conducts a full-text search of all the documents in a database.
Defined in
NotesDatabaseSyntax
FTSearchRange(query:string, max:int, sortopt:int, otheropt:int, start:int) : NotesDocumentCollection
Parameter | Description |
---|---|
query |
The full-text query. See the section "Query Syntax" that follows. |
max |
The maximum number of documents you want returned from the query. Set this parameter to 0 to receive all matching documents. |
sortopt |
Sorting option:
|
otheropt |
Additional search options. To specify more than
one option, add them.
|
Return value | Description |
---|---|
NotesDocumentCollection | 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. |
Usage
This method is the same the same as FTSearch plus the start parameter.If the database is not full-text indexed, this method works, but less efficiently. To test for an index, use isFTIndexed. To create an index, use createFTIndex or updateFTIndex.
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. 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 NotesView. To search only documents found in a particular document collection, use the FTSearch method in NotesDocumentCollection.
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.
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. A NotesNewsletter 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.
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. You can also search for "query syntax" in the Domino® Designer Eclipse help system.
Examples
This button returns all the documents in the current database that contain a user-specified string, in groups of eight.database.updateFTIndex(true);
var query:string = requestScope.query;
if (!query.isEmpty()) {
query = "\"" + query + "\"";
var start:int = 1;
// Get the first 8 documents that match the query
var dc:NotesDocumentCollection = database.FTSearchRange(query, 8,
NotesDatabase.FT_SCORES, NotesDatabase.FT_STEMS, start);
if (dc.getCount() == 0) {
requestScope.status = "No matches";
return;
}
requestScope.status = "";
while (dc.getCount() > 0) {
// Display subject for documents matching query
requestScope.status = requestScope.status + "\nSearch results "
+ start + " - " + (start - 1 + dc.getCount());
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
requestScope.status = requestScope.status + "\n\t" + doc.getItemValueString("Subject");
var tmpdoc = dc.getNextDocument();
doc.recycle();
doc = tmpdoc;
}
// Get next 8 documents that match the query
start = start + 8;
dc = database.FTSearchRange(query, 8,
NotesDatabase.FT_SCORES, NotesDatabase.FT_STEMS, start);
}
}