How to sort only by frequency of the keyword


I meet a situation that search results should be sorted only by the
frequency of the keyword in the document. Since the default score
calculating considers many other factor, I cannot just sort by score. Is
there a way to specify how to calculate the score, or any way to achieve
the effect.