Debugging the Score Function

You can debug the score functions using the debug_info(str message, float var)function. The function allows to create and store tuples of messages and numeric values, as part of the query results.

Input

  • message(str) - the message to be printed after the run

  • var(float or int) - a variable to be stored as part of the message

Output

  • (str) - a message that includes the printed output.

Example:

def score_function(doc, params):
    if match(fieldname_doc = "ips", fieldname_params="ips"):
        a = 1.0
        score = a + 1
        debug_info("the first score is", score)
        if match(fieldname_doc = "ips", fieldname_params="ips"):
            score = 3.0 
            debug_info("the second score is", score)
        return score
    return 0

In the above example -

The search results will include two additional keys per candidate, stored under the "similarity" key, corresponding to the messages created using debug_info in the score function.

"similarity":
[
    {
    "document_id": "doc_1",
    "the first score is": 2.0
    "the second score is": 3,
    }
    ...
]

Last updated