searchResults method

Note: STABLE.
This API is reliable and breaking changes are unlikely.

qlik.app.searchResults(qTerms, qPage, qOptions, callback)

Searches for one or more terms in the values of a Qlik Sense app.

Version history

Introduced 2.2

Parameters

Name Type Description
qTerms Array

Optional.

Terms to search for.

qPage Object

Optional.

Properties:

Name Type Description
qOffset Number Position from the top, starting from 0.
qCount Number Number of search results to return.
qGroupOptions Array

This parameter is optional.

Options of the search groups.

If this property is not set, all values are returned.

qGroupItemOptions Array

This parameter is optional.

Options of the search group items.

If this property is not set, all values are returned.

qOptions Object

Optional.

Search options.

Properties:

Name Type Description
qSearchFields Array List of search fields.
qContext  

Search context. Can be one of:

  • Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app.
  • LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values.
  • CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context.

Default value is LockedFieldsOnly.

callback Function

Optional.

Callback method.

Returns

A promise of a Qlik Associative Engine reply.

Tip: For more information regarding a promise, see https://code.angularjs.org/1.5.8/docs/api/ng/service/$q#the-promise-api.

Example

app.searchResults( ["ma"],
		{ qOffset: 0, qCount: 15},
		{qContext: 'CurrentSelections'},
function ( reply ) {
		if ( reply.qResult.qTotalNumberOfGroups === 0 ) {
	alert('No matches');
		} else {
	var str = "";
		reply.qResult.qSearchGroupArray.forEach( function ( value ) {
				value.qItems.forEach( function ( item ) {
			str += item.qIdentifier +": ";
				item.qItemMatches.forEach( function ( match ) {
					str += match.qText + ' ';
			} );
		} );
	} );
	alert(str);
 }
 });

Did this information help you?

Can you tell us why it did not help you and how we can improve it?