Filter Results

In some cases, you might want to restrict the results that a user receives as suggestions. You can apply filters to the TypeAhead action, depending on the mode that you are using.

Use a SecurityInfo String

When you are using the data index to provide suggestions, you can use the IDOL security functionality to ensure that users see only suggestions that occur in at least one document that they are permitted to see.

You can set the SecurityInfo parameter in the TypeAhead action. HPE QMS forwards this value to the IDOL Content component, which filters the results according to user permissions. You can generate the SecurityInfo string for a user by using the UserRead action for the IDOL Server Community component. For more information, refer to the IDOL Server Reference.

Use a Lua Script to Filter Results

You can configure and use a Lua script to filter the suggestions according to your own filtering criteria.

The Lua script that you create to filter results must contain a valid Lua function named typeahead_filter that accepts a string value and returns a Boolean value.

HPE QMS calls the Lua script once for each suggestion that the TypeAhead action returns. It passes the suggestion to the prefix argument of the typeahead_filter function. The following script is a very simple example, which filters out the suggestion gold, if it returns from HPE QMS:

function typeahead_filter (prefix)
   if prefix == "gold" then
      return false
   return true

When you have a script configured, the TypeAhead action returns only suggestions for which the typeahead_filter function returns True. In the example above, the suggestion gold returns False, so HPE QMS does not show it in the response for the TypeAhead action.