in reply to Search a database for every permutation of a list of words

IF you just want to rank documents in terms of how many query terms (@term = qw{hairline receding} in your example) each document contains, you don't need to do any permuting.

Note that there are various trade-offs of memory, disk space, and search time that you can make. You'll need to analyze carefully what a "typical" query is like, and what a "bad" query is like, and take appropriate measures.

Here's A Way To Do It. I assume you have (or will manufacture) a list of all search terms.

"Interesting" parts include dealing with very large indexes (if your collection of documents is large), stemming words, and selecting the relevant words.

A good alternative might be to get a 3rd-party search engine instead of writing your own.