I guess I can come up with two different approaches. Since you're asking about search relevance I assume you want som kind of sorting depending on this relevance.
You want to compare your input with the search result. Then it's natural to retrieve info on occurences of the query, occurences of each part of the query and how your query matches(or almost matches) the content of the result. You pretty much have to decide the rules here.
If your result set is a bunch of names, locations or whatever, you have the option of comparing text using an algorithm implemented in PHP.
Important: This will not work when your result is a regular text. Your input must be somewhat similar to the output.
example:
$input: jon
$result:
jon
jonn
jonno
jonno946
Try out this code...
similar_text( $input, $result, $percentage );
print $percentage;
The value of the $percentage variable will be different for each result:
jon is a 100% match
jonn is a 85.7142857143% match
jonno is 75% match
jonno946 is a 54.5454545455% match
Knowing all this, you can sort it the way you want it.
Hope this can give you some ideas.