debug_info

debug_info(str message, float var)allows to print message and variables from the score function. The output will be saved under the search result.

This function is a useful tool to assist in debug of the score function.

Input

  • message(str) - the message to be saved in the search result.

  • 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(params, doc):
    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