PrizmDoc® Viewer v13.28 Release - Updated
PrizmDoc Viewer / API Reference / Viewer Control / Namespace: PCCViewer / Class: SearchTask
In This Topic
    Class: SearchTask
    In This Topic

    PCCViewer. SearchTask

    This object represent a search task, which can be used to perform searches on any text string.

    The PCCViewer.SearchTask.search method on the PCCViewer.SearchTask object can be used to search text contained in the Mark and comments objects. It will also perform search on any other text string.

    Constructor

    new SearchTask(searchQuery)

    Creates a SearchTask object used for searching any text string.

    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.");
    
    

    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.

    See:

    Throws:

    • If search query is not a string or a valid PCCViewer.ViewerControl~SearchQuery object.

      Type
      Error
    • When using the SearchQuery object, if the searchQuery.searchTerm is not an Array.

      Type
      Error
    • When using the SearchQuery object, if the searchQuery.searchTerms[i].searchTerm property of each Object in the searchTerms 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

    Methods

    Searches any text string using the search criteria that were provided to the PCCViewer.SearchTask constructor.

    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);
    
    

    Parameters:

    Name Type Description
    text string

    The text string to be searched.

    Returns:

    An array of PCCViewer.SearchTaskResult objects.

    Type
    Array.<PCCViewer.SearchTaskResult>

    Documentation generated by JSDoc 3.6.10 on Sun Feb 25 2024 19:35:20 GMT+0000 (Coordinated Universal Time)