Get entries related to tags with a score & order by
You can add custom properties to elements using behaviors. In this case you want to add your 'getSearchScore()' logic.

Here's a good article on how behaviors work in Craft CMS and a current PR on the documentation to have behaviors information added.