Answer Server 23.2

# Test Your Question Equivalence Rule

When you create a question equivalence rule, you can check that it matches all the questions that you want to include in the question equivalence class, and that it does not match questions that belong to other question equivalence classes. The `GetResources` action has several filters that you can use to test your rules.

You can also use the `TestRule` action to test whether a particular set of questions matches a rule that you specify. In this case, you do not need to have indexed the questions or the question equivalence rule.

NOTE: The `TestRule` action can test only rules that use simple text (with any Boolean and proximity expressions). You cannot test `FieldText` rules in this way. For more information about `FieldText` rules, see Special Rule Types.

## Find Questions that Do Not Match the Rule

You can add the question equivalence rule text as a text filter in `GetResources`, to find questions that match or do not match the rule. You can also specify a list of IDs for questions that you want to match the rule in the `IDs` parameter.

TIP: You can retrieve a list of question IDs and the rule for a question equivalence class by sending a `GetResources` action with `Type` set to `question_equivalence_class`.

To test whether the rule matches the questions in the question equivalence class, set the text filter to `NOT(RuleText)`, and set `IDs` to a list of IDs of the questions in that class.

For example:

    http://localhost:12000?Action=GetResources&Type=question&IDs=9706856188043740111,8129920660480699726,3067998369792637739&Filter=%7B%20%22text%22%20%3A%20%22NOT(updates%20AND%C2%A0MyCompany)%22%20%7D

The `Filter` parameter takes a percent-encoded JSON object, which contains the filters to apply. In this case, the unencoded JSON object is:

    { "text" : "NOT(updates AND MyCompany)" }

This action returns any questions in the list of IDs that do not match the question equivalence rule `updates AND MyCompany`.

## Find Questions in Other Classes that Match the Rule

After you create the question equivalence class and add the rule, you can also use `GetResources` to find out if your rule matches any questions that do not belong to the class, by using the `not_associated_with` filter.

For example, for a `GetResources` action with `Type` set to `question`, the following filter object matches questions that match the rule `updates AND MyCompany`, and that do not belong to the question equivalence class with ID 1429393462892614629.

    {
       "text" : "updates AND MyCompany",
       "not_associated_with": [
          {
             "ids": [
                "1429393462892614629"
             ],
             "type": "question_equivalence_class"
          }
       ]
    }

This filter returns questions that match the rule that already belong to a different question equivalence class. This might indicate that your rule is not restrictive enough.

TIP: This filter also returns any questions that match the rule and that do not belong to a question equivalence class. If you want to find only questions that belong to a different question equivalence class, you can add an additional `state` filter to find questions in the `answered` state.

## Test Whether Questions Match a Specified Rule

You can use the `TestRule` action to test questions and rules that you have not added to the Answer Bank Agentstore. This action allows you to test rules and questions before you index them, to save indexing time, and reindexing time if you need to change the rule.

To use `TestRule`, you specify the questions in a JSON object in the `Questions` parameter, and the rule in the `Rule` parameter. You must also set `SystemName` to the name of the Answer Bank system.

For example:

    action=TestRule&SystemName=MyAnswerBank&Questions={"text":["Why is the sky blue?","What causes the sky to appear blue?","How do I return a defective item?"],"ids":["7660794084496396635","15927917885427259786","14042282250303108454"]}&Rule=sky AND blue

This action tests whether the questions Why is the sky blue?, What causes the sky to appear blue?, and How do I return a defective item?, and the questions with IDs 7660794084496396635, 15927917885427259786, and 14042282250303108454 match the rule `sky AND blue`.

The action returns the rule, with a `matched` property that contains the list of matching questions, and the `not_matched` property that contains any questions in the request that do not match the rule.

    {
       "rule": "sky AND blue",
       "matched": {
          "text": [
             "Why is the sky blue?",
             "What causes the sky to appear blue?"
          ],
          "id" [
             "15927917885427259786",
             "14042282250303108454"
          ]
       },
       "not_matched": {
          "text": [
             "How do I return a defective item?"
          ],
          "id": [
            "7660794084496396635"
          ]
       }
    }

Copyright 2016-2023 Open Text
Version 23.2 | Last updated March 2023

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to swpdl.idoldocsfeedback@microfocus.com.

We appreciate your feedback!

Product: IDOL Answer Server 23.2

Topic Title: Test Your Question Equivalence Rule