How can we rank search results?

We store frequency as well in our table:

TermDoc_idFreqPostings
“asd”130, 5, 10
“sss”121, 2

As you can see, “asd” appears 3 times: “0, 5, 10” in document 1. Hence we say it appears 3 times (Freq = 3)

It has higher ranking than “sss” overall in the same document, since it appears thrice, whereas “sss” appears twice.