I've never done this, and for all I know it could bring your app to a screeching halt, but...
You could try creating an 'index' table that has:
1) The word
2) The word's position in the document
3) The URI to the document
Index 1 and 2. Then, do (something like):
SELECT STDEV(position) as prox, uri FROM INDEX_TABLE WHERE word IN ('word1','word2','word3') GROUP BY uri, prox ORDER BY prox
The smaller the standard deviation, the closer the words are together. I don't think the above code will work as-is, but you could give it a try.
--Ernest