Open topic with navigation

# 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.

- In Index mode, you can use a `SecurityInfo` string with the `TypeAhead` action. HPE QMS forwards this string to the IDOL index, and returns only terms that occur in documents that the user is permitted to see.

- In both Index and Dictionary mode, you can provide a Lua script that filters the suggestions that the `TypeAhead` action returns.

## 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
       end
       return true
    end

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.

To configure QMS to use a Lua script for filtering

1. Open the HPE QMS configuration file in a text editor.

2. Find the `[TypeAhead]` configuration section, or create one if it does not exist.

3. Set the `Script` parameter to the name of the script file that you want to use. For example:

       [TypeAhead]
       Script=filter_script.lua

4. Save and close the HPE QMS configuration file. Restart HPE QMS for your changes to take effect.

© 2017 Hewlett Packard Enterprise Development LP | Send documentation feedback to HPE Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to AutonomyTPFeedback@hpe.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_HP_HTML5_bannerTitle.htm