The SearchResults class

Support in HbbTV

Available since: HbbTV 1.5 (ETSI TS 102 796 V1.2.1, OIPF DAE V1.2)

Comment

Broadcast-related

The SearchResults class represents the results of a metadata search. Since the result set may contain a large number of items, applications request a ‘window’ on to the result set, similar to the functionality provided by the OFFSET and LIMIT clauses in SQL.

Applications MAY request the contents of the result in groups of an arbitrary size, based on an offset from the beginning of the result set. The data SHALL be fetched from the appropriate source, and the application SHALL be notified when the data is available.

The set of results SHALL only be valid if a call to getResults()has been made and a MetadataSearch event notifying the application that results are available has been dispatched. If this event has not been dispatched, the set of results SHALL be empty (i.e. the value of the totalSize property SHALL be 0 and calls to item() SHALL return undefined).

In addition to the properties and methods defined below a SearchResults object SHALL support the array notation to access the results in this collection.

Properties

readonly Integer length
The number of items in the current window within the overall result set. The value of this property SHALL be zero until getResults()has been called and a MetadataSearch event notifying the application that results are available has been dispatched. If the current window onto the result set is in fact the whole result set then length will be the same as totalSize. Otherwise length will be less than totalSize.
readonly Integer offset
The current offset into the total result set.
readonly Integer totalSize
The total number of items in the result set. The value of this property SHALL be zero until getResults() has been called and a MetadataSearch event notifying the application that results are available has been dispatched.

Methods

Object item( Integer index )

Description

Return the item at position index in the collection of currently available results, or undefined if no item is present at that position. This function SHALL only return objects that are instances of Programme, CODAsset, CODFolder, or CODService.

Arguments

index

The index into the result set.

Boolean getResults( Integer offset, Integer count )

Description

Perform the search and retrieve the specified subset of the items that match the query.

Results SHALL be returned asynchronously. A MetadataSearch event with state=0 SHALL be dispatched when results are available.

This method SHALL always return false.

Arguments

offset

The number of items at the start of the result set to be skipped before data is retrieved.

count

The number of results to retrieve.

void abort()

Description

Abort any outstanding request for results and remove any query, constraints or ordering rules set on the MetadataSearch object that is associated with this SearchResults object. Regardless of whether or not there is an outstanding request for results, items currently in the collection SHALL be removed (i.e. the value of the length property SHALL be 0 and any calls to item()SHALL return undefined). All cached search results SHALL be discarded.