A client asked me for the same thing and I built a routine to search text files (HTML files and text files) looking for strings of text. The client didn't tell me that they had 20,000 emails that were stored as text files and those would be subject to the search as well. With only a few hundred text files, it was taking 20 seconds to find the matching pages. We never tested it with the whole 20,000 text files.
So then I found Swish-E (free, open source). It searches all 20,000 text files in less than 1 second. And all the work for Search Engine type queries is already done for you. Boolean logic, grouping by parentheses, etc. It took me about an hour to install and configure it. You write a PHP script that makes calls out to Swish-E, it returns the results, and you write your PHP page to display the results (or act on the results) any way you want. Major major time saver.