Prizm Content Connect
Class: SearchRequest

Class: SearchRequest

PCCViewer. SearchRequest

<protected> new SearchRequest()

The SearchRequest object is created when searching a document. It triggers events to indicate search progress and it has properties to get the search results and status.

This constructor should not be used directly. Instead, a search request is created by PCCViewer.ViewerControl#search, and it is also made available through the PCCViewer.EventType.SearchPerformed event.

Example
// A SearchRequest object is created by and returned from the call to the search method
var serachRequest = viewerControl.search("FooBar");

Members

<readonly> errorCode :number

Gets the error code if there was an error. If there was no error, null will be returned.

An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

Type:
  • number
See:

<readonly> errorMessage :string

Returns a plain text, human-readable, fixed-local message that explains the error condition. If there was no error, null will be returned.

An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

Type:
  • string
See:

<readonly> isComplete :boolean

Gets a value (true or false) indicating if the search request is complete.

An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

Type:
  • boolean
See:

<readonly> results :Array.<PCCViewer.SearchResult>

Gets an array of all search results produced by this SearchRequest up until this point.

An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

Type:
See:

<readonly> searchQuery :string

Gets the search query passed to PCCViewer.ViewerControl#search.

If a string was passed to the search method, then this will return a PCCViewer.ViewerControl~SearchQuery object. The object will contain one search term (the provided string) and the options used for searching.

If an incomplete PCCViewer.ViewerControl~SearchQuery object was passed to search, then the object will be augmented with all options used for searching.

An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

Type:
  • string
See:

Methods

cancel()

Cancels the current search execution and triggers SearchCancelled event.

Example
searchRequest.cancel();

getErrorCode() → {number}

Returns the error code if there was an error. If there was no error, null will be returned.

Returns:

An error code indicating the type of error, or null.

The possible error codes are:

  • 1010 - An unexpected exception occurred.
  • 1011 - There was a failure retrieving data from the server.
Type
number
Example
var errorCode = searchRequest.getErrorCode();

getErrorMessage() → {string}

Returns a plain text, human-readable, fixed-local message that explains the error condition. If there was no error, null will be returned.

Returns:

A plain text error message that explains the error condition, or null.

Type
string
Example
var errorMessage = searchRequest.getErrorMessage();

getIsComplete() → {boolean}

Returns a value (true or false) indicating if the search request is complete.

Returns:

A value indicating if search is complete.

Type
boolean
Example

var status = searchRequest.getIsComplete();  // true if search is complete

getPagesWithoutText() → {Array.<number>}

Returns an array of page numbers that could not be searched because searchable text was not available for the page.

The set of pages without searchable text may still contain text embedded in a rasterized image, but the viewer is unable to detect or search this text. Therefore it is useful to notify the end user when some pages could not be searched.

Returns:

Returns an array of page numbers, or an empty array if all pages had searchable text.

Type
Array.<number>
Example
// Use pagesWithoutText to alert the end user that some pages could not be search.
var pagesWithoutText = searchRequest.getPagesWithoutText();

getResults() → {Array.<PCCViewer.SearchResult>}

Returns an array of all search results produced by this SearchRequest up until this point.

Returns:

An array of SearchResult objects. If no results are found, this will be an empty array.

Type
Array.<PCCViewer.SearchResult>
Example

var searchResults = searchRequest.getResults();

getSearchQuery() → {PCCViewer.ViewerControl~SearchQuery}

Returns the search query passed to PCCViewer.ViewerControl#search.

If a string was passed to the search method, then this will return a PCCViewer.ViewerControl~SearchQuery object. The object will contain one search term (the provided string) and the options used for searching.

If an incomplete PCCViewer.ViewerControl~SearchQuery object was passed to search, then the object will be augmented with all options used for searching.

Returns:

The search query for this search request.

Type
PCCViewer.ViewerControl~SearchQuery
Example
var searchQuery = searchRequest.getSearchQuery();

off(eventType, handler) → {PCCViewer.SearchRequest}

Unsubscribe a handler from an event of the SearchRequest.

Typically, event is unsubscribed when you no longer want further notification of the event.

Parameters:
Name Type Description
eventType string

A string specifying the event type. See PCCViewer.SearchRequest#on for possible values.

handler function

The function that was previously subscribed to the event type.

Returns:

The SearchRequest object on which this method was called.

Type
PCCViewer.SearchRequest
Example
// subscribe
searchRequest.on(PCCViewer.EventType.SearchCompleted, onSearchCompleted);

// unsubscribe
searchRequest.off(PCCViewer.EventType.SearchCompleted, onSearchCompleted);

// handler declaration
function onSearchCompleted(ev) {
    alert("Search completed! Number of hits :" + searchRequest.getResults().length);
}

on(eventType, handler) → {PCCViewer.SearchRequest}

Subscribe a handler to an event of the SearchRequest.

Parameters:
Name Type Description
eventType string

A string that specifies the event type.

handler function

The function that will be called whenever the event is triggered.

Returns:

The SearchRequest object on which this method was called.

Type
PCCViewer.SearchRequest
Example
// subscribe
searchRequest.on(PCCViewer.EventType.SearchCompleted, onSearchCompleted);

// handler declaration
function onSearchCompleted(ev) {
    alert("Search completed! Number of hits :" + searchRequest.getResults().length);
}

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback