You need to create a structure called inverse index, which maps each word (or may be if you want even phrases to documents). Wiki page nicely documents the process and it is really straight forward.
Than you can store this structure in your database (this will be done only once in a preprocessing step) and later might be changed when you add new Doc, or Docx files.
When a user inserts his words, you search not in the files, but in your database, which will be fast and will leverage indexes.