Constructor
new SearchTask(searchQuery)
Creates a SearchTask
object used for searching any text string.
Parameters:
Name | Type | Description |
---|---|---|
searchQuery |
string | PCCViewer.ViewerControl~SearchQuery |
A value specifying the search query. The value specifies a single search term (string) or an object specifying multiple search terms and options. NOTE: The searchQuery can be a single search term or a hash specifying one or more terms and options. If only a single search term (string) is supplied, then default options are used. |
Throws:
-
-
If search query is not a string or a valid PCCViewer.ViewerControl~SearchQuery object.
- Type
- Error
-
-
-
When using the
SearchQuery
object, if thesearchQuery.searchTerm
is not an Array.- Type
- Error
-
-
-
When using the
SearchQuery
object, if thesearchQuery.searchTerms[i].searchTerm
property of each Object in thesearchTerms
array is not a string.- Type
- Error
-
-
-
If the combination of a search terms and matching options results in an invalid search, such as performing a wildcard search with only a
*
character and no valid content.- Type
- Error
-
Example
// Search on multiple terms and specify options
var searchQuery = {
searchTerms: [{
searchTerm: "Full",
contextPadding: 10,
highlightColor: '#B22222',
matchingOptions: {
beginsWith: true
}
}]
};
// create a text annotation
var mark1 = viewerControl.addMark(1, "TextAnnotation");
// set text in the text annotation
mark1.setText("When Full-Text Search is being installed for an existing client without Full-Text Search");
// create PCCViewer.SearchTask object
var searchTask = new PCCViewer.SearchTask(searchQuery);
// use the method PCCViewer.SearchTask.search to search the word "Full" in the annotation text
var results = searchTask.search(mark1.getText());
// use it to search some other text string
var results2 = searchTask.search("To enable the full-text search functionality, your system should have a dedicated server.");
Methods
search(The) → {Array.<PCCViewer.SearchTaskResult>}
Searches any text string using the search criteria that were provided to the PCCViewer.SearchTask constructor.
Parameters:
Name | Type | Description |
---|---|---|
The |
string |
text string to be searched. |
Returns:
An array of PCCViewer.SearchTaskResult objects.
- Type
- Array.<PCCViewer.SearchTaskResult>
Example
var searchQuery = {
searchTerms: [{
searchTerm: "client",
contextPadding: 10,
highlightColor: '#B22222',
matchingOptions: {
beginsWith: true,
}
}]
};
var textString = "When Full-Text Search is being installed for an existing client without Full-Text Search";
var searchTask = new PCCViewer.SearchTask(searchQuery);
//search the textString
var results = searchTask.search(textString);