Under vanilla sphinx, this is done with, at conf.py
html_search_scorer = "path/to/scorer.js"
and here is a custom scorer example: https://github.com/zephyrproject-rtos/zephyr/blob/main/doc/_static/js/scorer.js
what can be done is doctools catching html_search_scorer and adding to a metadata file. then the extra.js/search grabs it and applies.