FTSearchSorted (NotesView - JavaScript)

Conducts a full-text search on all documents in a view and filters the view so it represents only those documents that match the full-text query in sorted order.

Defined in

NotesView

Syntax

FTSearchSorted(query:string) : int

FTSearchSorted(query:string, maxdocs:int) : int

FTSearchSorted(query:string, maxdocs:int, column:string) : int

FTSearchSorted(query:string, maxdocs:int, column:string, ascending:boolean, exact:boolean, variants:boolean, fuzzy:boolean) : int

FTSearchSorted(query:string, maxdocs:int, column:int) : int

FTSearchSorted(query:string, maxdocs:int, column:int, ascending:boolean, exact:boolean, variants:boolean, fuzzy:boolean) : int

FTSearchSorted(query:java.util.Vector) : int

FTSearchSorted(query:java.util.Vector, maxdocs:int) : int

FTSearchSorted(query:java.util.Vector, maxdocs:int, column:string) : int

FTSearchSorted(query:java.util.Vector, maxdocs:int, column:string, ascending:boolean, exact:boolean, variants:boolean, fuzzy:boolean) : int

FTSearchSorted(query:java.util.Vector, maxdocs:int, column:int) : int

FTSearchSorted(query:java.util.Vector, maxdocs:int, column:int, ascending:boolean, exact:boolean, variants:boolean, fuzzy:boolean) : int

Parameter Description
query The full-text query or the intersection of multiple queries. See below for the query syntax.
maxdocs The maximum number of documents you want returned from the search. If you want to receive all documents that match the query, specify 0. Defaults to 0.
column The name or 0-based index of a sorted column. A specification of NotesView.VIEW_FTSS_RELEVANCE_ORDER (512) returns results in relevance order while honoring the use of the extended flags for exact case, variants, and fuzzy search.
ascending Sorts column data in ascending order if true, descending order if false. Defaults to true. Ignored if NotesView.VIEW_FTSS_RELEVANCE_ORDER is in effect.

The availability of a column to be sorted in ascending or descending order is determined by "Click on column header to sort" on the Sorting tab of the column properties. The relevant options are Ascending, Descending, and Both. Trying to sort a column in an unsupported direction throws an exception.

exact Applies exact case to the search if true. Defaults to false.
variants Returns word variants in the search results if true. Defaults to false.
fuzzy Returns misspelled words in the search results if true. Defaults to false.
Return value Description
int The number of documents in the view after the search. Each of these documents matches the query.

Usage

After calling this method, you can use the regular NotesView methods to navigate the result, which is a subset of the documents in the view. If the database is not full-text indexed, the documents in the subset are in the same order as they are in the original view. However, if the database is full-text indexed, the documents in the subset are sorted into descending order of relevance. The method getFirstDocument returns the first document in the subset, getLastDocument returns the last document, and so on.

Use the clear method to clear the full-text search filtering. The NotesView methods now navigate to the full set of documents in the view.

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 on a local database, use updateFTIndex.

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 displays document values from a view searched and sorted according to a named column.
if (database.isFTIndexed()) {
	database.updateFTIndex(false)
} else {
	database.createFTIndex(0, true)
}
requestScope.status = "";
var v:NotesView = database.getView("main");
if (requestScope.query1 == null) return;
if (v.FTSearchSorted(requestScope.query1, 0, "year") == 0) return;
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
	requestScope.status += "\n" + 
		doc.getItemValueString("model") + " " +
		doc.getItemValueString("color") + " " +
		doc.getItemValueString("year");
	var tmpdoc = v.getNextDocument(doc);
	doc.recycle();
	doc = tmpdoc;
}
This button displays document values from a view searched and sorted according to relevance.
if (database.isFTIndexed()) {
	database.updateFTIndex(false)
} else {
	database.createFTIndex(0, true)
}
requestScope.status = "";
var v:NotesView = database.getView("main");
if (requestScope.query1 == null) return;
if (v.FTSearchSorted(requestScope.query1, 0, NotesView.VIEW_FTSS_RELEVANCE_ORDER) == 0) return;
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
	requestScope.status += "\n" + 
		doc.getItemValueString("model") + " " +
		doc.getItemValueString("color") + " " +
		doc.getItemValueString("year");
	var tmpdoc = v.getNextDocument(doc);
	doc.recycle();
	doc = tmpdoc;
}
This button displays document values from a view searched with two queries, and sorted according to the first column.
if (database.isFTIndexed()) {
	database.updateFTIndex(false)
} else {
	database.createFTIndex(0, true)
}
requestScope.status = "";
var v:NotesView = database.getView("main");
if (requestScope.query1 == null) return;
if (requestScope.query2 == null) return;
var query = new java.util.Vector();
query.add(requestScope.query1);
query.add(requestScope.query2);
if (v.FTSearchSorted(query, 0, 0) == 0) return;
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
	requestScope.status += "\n" + 
		doc.getItemValueString("model") + " " +
		doc.getItemValueString("color") + " " +
		doc.getItemValueString("year");
	var tmpdoc = v.getNextDocument(doc);
	doc.recycle();
	doc = tmpdoc;
}
This button displays document values from a view searched and sorted according to the second column in descending order with variants and a fuzzy search allowed. Results are limited to 4.
if (database.isFTIndexed()) {
	database.updateFTIndex(false)
} else {
	database.createFTIndex(0, true)
}
requestScope.status = "";
var v:NotesView = database.getView("main");
if (requestScope.query1 == null) return;
if (v.FTSearchSorted(requestScope.query1, 4, 1, false, false, true, true) == 0) return;
var doc:NotesDocument = v.getFirstDocument();
while (doc != null) {
	requestScope.status += "\n" + 
		doc.getItemValueString("model") + " " +
		doc.getItemValueString("color") + " " +
		doc.getItemValueString("year");
	var tmpdoc = v.getNextDocument(doc);
	doc.recycle();
	doc = tmpdoc;
}